-
Notifications
You must be signed in to change notification settings - Fork 902
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
functions emulator crashes when accessing config in global space #4158
Comments
I would like to mention that 10.2 emulator functions broke entirely for me, though they load fine, and I don't notice anything unusual in the logs, other than my functions no longer work. Some of the functions do launch and complete once, but not repeatedly, as I'm using a lot of pubsub cron tasks, also database triggers, etc. 10.1.5 works perfectly, as does the most recent 9.x, and I'm up to date on all other dependencies. I see no errors anywhere, but functions tend to hang, and I have a long wait for them to timeout or I just force kill them along with all the emulators. I compared what got changed in 10.2 from 10.1.5 and there's too much there for me to have insights without any feedback in the logs. A better series of test cases, exercising the whole API as I'm doing, seems needed to avoid such buggy releases. Thanks for all your work on this! |
@danbraik I've think I had the same problem. The solution for me was to move the .runtimeconfig.json from the functions folder to the root folder, where my npm script was being called. |
@eriklundstrom That may make sense since 10.2 uses the env.local approach to setting config information...but it didn't solve my problem. Further investigations show that the emulator now "sleeps" perhaps like Cloud Functions do, and my workaround to the still-vexing #2034 with SetInterval calls isn't enough to "wake up" the functions I'm calling, and perhaps the same issue results in deadlocks and hung functions as I continue to see in 10.2. Perhaps I would also see these problems on the server (I have never tested on a real firebase server bion, I'm just working in the emulators) but on the real server #2034 wouldn't be a problem either. That bug has been left alive far, far too long, and it may be sticking me and anyone else scheduling functions on the emulators back on 10.1.5 for now. |
@eriklundstrom that doesn't fix it for me, the functions build with that change but if you then call them you'll see the same errors. |
Hey folks thanks for reporting the issue and chiming in. Looks like one obvious bug is that functions config are no longer loaded when trying to parse function triggers defined in the source. @spicemix Your reported issue is alarming. Could you help us out by filing another bug w/ a small reproducible issue if you have time? |
Greatly appreciated if the fix can be expedited as our work has been stopped for more than 3 days. Our code depends too much on the cloud functions environment variables for our email notifications to be sent programmatically through the OAuth2 credentials stored in it. We're unable to do the testing and debugging for the new features of our app to be rolled out on time. If this is gonna take time, is there a way to safely rollback to the earlier working version so that we can continue our work while waiting for the fix to be available? Please advise, thank you so much! |
% npm i -g firebase-tools@10.1.5 If that turns out somehow "unsafe" for you, this will get you back to where we are now: % npm i -g firebase-tools |
@taeold I think the repro for me would just be scheduled functions in the emulator as in #2034 The workaround I'm using is based upon But right now I'm not sure 10.2 offers me enough value over 10.1.5 to upgrade until you've got #2034 finally implemented. Maybe 10.2 is a better test for the Cloud version, but without PubSub scheduled functions, it fails to serve as one right from the get-go for me. I don't know why someone there did all that work on a PubSub emulation without finishing the job. Cron tasks are, you know, kinda important for datastore maintenance and such. And PubSub is the official way to run them on Google Cloud. And I want to use the emulator to develop and test them. And I can't. Update 2/17/22: 10.2.1 does not fix my problem. |
Thank you so much! Do I need to issue this first for a cleaner downgrade? Would that cause any side effect? |
@antoniooi Generally, you don't need to issue the To double check, print the version after you run your command:
|
Ok guys, rolling back to |
@taeold I'm having rules issues with the storage emulator on 10.2.2. Rolling back to 10.1.5 fixes it. My issue does not seem to be related to spicemix's issues In our use case, we have Auth using V9, and storage lib using compat V8. Does the fix on 10.2.1 include fixes for the compat v8 lib? Upload fails with "not authorized" error as if the rules did not permit the operation Thanks! |
[REQUIRED] Environment info
**firebase-tools:**10.2.0
**Platform:**Debian
[REQUIRED] Test case
initialise a project with functions emulator
functions/src/index.ts
import * as functions from "firebase-functions"; const a = functions.config().stripe.stripe_secret_key;
add .runtimeconfig.json
{ "stripe": { "stripe_secret_key": "hello" } }
[REQUIRED] Steps to reproduce
$ npm run build
$ firebase emulators:start --only functions
[REQUIRED] Expected behavior
I expect the emulator to be launched, as in previous version ( <= 10.1.5)
[REQUIRED] Actual behavior
There is an error for accessing config during global space initialisation (it works when it is called later)
`
Error: Error occurred while parsing your function triggers.
TypeError: Cannot read property 'stripe_secret_key' of undefined
at Object. (.../functions/lib/functions/src/index.js:16:36)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at loadModule (.../.npm-global/lib/node_modules/firebase-tools/lib/deploy/functions/runtimes/node/triggerParser.js:10:16)
at .../.npm-global/lib/node_modules/firebase-tools/lib/deploy/functions/runtimes/node/triggerParser.js:34:21
at Object. (...npm-global/lib/node_modules/firebase-tools/lib/deploy/functions/runtimes/node/triggerParser.js:72:3)
`
The text was updated successfully, but these errors were encountered: