Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloud functions not working with Quickstart project #1345

Closed
xn1cklas opened this issue Aug 4, 2023 · 2 comments
Closed

Cloud functions not working with Quickstart project #1345

xn1cklas opened this issue Aug 4, 2023 · 2 comments
Labels
new New issue.

Comments

@xn1cklas
Copy link

xn1cklas commented Aug 4, 2023

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2022.3.2f1
  • Firebase Unity SDK version: 11.3.0
  • NPM Version: 20.5.0, also tried 18.0
  • Source you installed the SDK: .unitypackage
  • Problematic Firebase Component: Function
  • Other Firebase Components in use: Auth
  • Additional SDKs you are using:
  • Platform you are using the Unity editor on: Mac
  • Platform you are targeting: Android
  • Scripting Runtime: Mono

[REQUIRED] Please describe the issue here:

Actually, I ran into two errors, not sure if they are connected. If not, I can move one to a separate issue.

NPM installation failed

Following the instructions from quickstart-unity/functions/testapp/readme.md

Move to the `Assets/Firebase/Sample/Functions/.functions` subdirectory of
the sample.

cd Assets/Firebase/Sample/Functions/.functions

# Install all of the dependencies of the cloud functions
cd functions
npm install
cd ..

This does not work. THere is no functions in Assets/Firebase/Sample/Functions/.functions
npm install doesn't work in neither of them, even though there are functionspackage.json they cannot be read by node/npm.

Error:

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/username/Directory/project-name/Assets/Firebase/Sample/Functions/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/username/Directory/project-name/Assets/Firebase/Sample/Functions/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

Unity cloud function exampleadd number not working

  Error: System.AggregateException: One or more errors occurred. (INTERNAL) ---> Firebase.Functions.FunctionsException: INTERNAL
  at Firebase.Functions.HttpsCallableReference.<CallAsync>b__9_0 (System.Threading.Tasks.Task`1[TResult] task) [0x00063] in <7a611edaa0f948979d1e886be7bbe8e0>:0 
  at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2[TAntecedentResult,TResult].InnerInvoke () [0x00024] in <130809ae6f984869a6663c878f16e3f3>:0 
  at System.Threading.Tasks.Task.Execute () [0x00000] in <130809ae6f984869a6663c878f16e3f3>:0 
   --- End of inner exception stack trace ---
---> (Inner Exception #0) Firebase.Functions.FunctionsException: INTERNAL
  at Firebase.Functions.HttpsCallableReference.<CallAsync>b__9_0 (System.Threading.Tasks.Task`1[TResult] task) [0x00063] in <7a611edaa0f948979d1e886be7bbe8e0>:0 
  at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2[TAntecedentResult,TResult].InnerInvoke () [0x00024] in <130809ae6f984869a6663c878f16e3f3>:0 
  at System.Threading.Tasks.Task.Execute () [0x00000] in <130809ae6f984869a6663c878f16e3f3>:0 <---

UnityEngine.Debug:Log (object)
Firebase.Sample.Functions.UIHandler:DebugLog (string) (at Assets/Firebase/Sample/Functions/UIHandler.cs:72)
Firebase.Sample.Functions.UIHandler/<>c__DisplayClass14_0:<AddNumbers>b__0 (System.Threading.Tasks.Task`1<Firebase.Functions.HttpsCallableResult>) (at Assets/Firebase/Sample/Functions/UIHandler.cs:109)
Firebase.Extensions.TaskExtension/<>c__DisplayClass4_1`1<Firebase.Functions.HttpsCallableResult>:<ContinueWithOnMainThread>b__1 ()
Firebase.Dispatcher/<>c__DisplayClass5_0`1<bool>:<RunAsync>b__0 ()
Firebase.ExceptionAggregator:Wrap (System.Action)
Firebase.Dispatcher:PollJobs ()
Firebase.Platform.FirebaseHandler:Update ()
Firebase.Platform.FirebaseMonoBehaviour:Update ()

Steps to reproduce:

  1. Forked the quickstart-unity repo
  2. Added the sample folder from the functions example
  3. followed the instructions step by step
@xn1cklas xn1cklas added the new New issue. label Aug 4, 2023
@google-oss-bot
Copy link

This issue does not seem to follow the issue template. Make sure you provide all the required information.

@AlmostMatt
Copy link
Contributor

AlmostMatt commented Aug 10, 2023

Thanks for reporting this. It seems that several files like functionspackage.json were meant to be functions/package.json
@paulinon submitted a fix for this, so you should be able to pull the latest version of the quickstart and then npm should detect the functions folder as a valid node project.

For your second issue, if the first issue prevented you from deploying the sample function, then it makes sense that addNumbers would have failed. The file .functions/functions/index.js defines a method named addNumbers, and after you have deployed this to your firebase project, when you run the testapp it will ask the server to run the addNumbers function, which will only work if it has already been deployed.

Feel free to re-open if the current fix was not sufficient.

@firebase firebase locked and limited conversation to collaborators Sep 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new New issue.
Projects
None yet
Development

No branches or pull requests

3 participants