Skip to content

P0 issue: accessing .auth() throwing error that util.promisify() was not receiving a function! breaks several of our applications #1295

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

Closed
pfinazzo opened this issue May 26, 2021 · 7 comments · Fixed by #1300

Comments

@pfinazzo
Copy link

pfinazzo commented May 26, 2021

[REQUIRED] Step 2: Describe your environment

  • Operating System version: Linux (Heroku Dyno)
  • Firebase SDK version: ^9.0.0
  • Firebase Product: auth
  • Node.js version: 10.6.0
  • NPM version: 6.7.0

[REQUIRED] Step 3: Describe the problem:

My Heroku Server randomly started crashing recently and wont boot back up (even though it works perfectly fine locally). If I comment out const firebaseAdmin = firebaseApp.auth() , then it deploys with no crash, but as soon as I comment it back in, it crashes. This is breaking our applications and so this has become a P0 issue for us. Any help would be greatly appreciated. I will post screenshots of the error and the line of code I commented out that fixed the error. Thank you!

Steps to reproduce:

Deploy a heroku server and import the firebase-admin sdk and call the .auth() method with the same node and npm env. This issue has arisen within the past week, I'm not sure exactly when it started.

Relevant Code:

Error:
Screen Shot 2021-05-25 at 7 20 00 PM

Fixed by commenting out:
Screen Shot 2021-05-25 at 7 20 48 PM

I've gone through and tested it several times over, and consistently this ^ is the line of code causing it to crash.

Again this is NOT happening locally but for some reason only on a deployed heroku dyno instance.

Any help on this would be SUPER appreciated because it is currently breaking several of our apps

our firebaseApp firebase configuration has been working perfectly up until around last week and the error does not get thrown until .auth() is called so Im inclined to believe we have everything set up properly, unless something has changed recently about how it should all be setup configuration wise

@pfinazzo
Copy link
Author

I downgraded my firebase-admin package to 8.4.0 and it works, so hopefully that can help narrow it down! Something deployed between 8.4.0 and now is definitely the source of the issue!

@pfinazzo pfinazzo changed the title P0 issue: accessing .auth() throwing error that util.promisify() was not receiving a function! breaks several of our applications, please review asap!! P0 issue: accessing .auth() throwing error that util.promisify() was not receiving a function! breaks several of our applications May 26, 2021
@lahirumaramba
Copy link
Member

Hi @pfinazzo,
Could you please confirm the exact firebase-admin version you used? The latest firebase-admin version is 9.8.0v. Do you still see the error if you use the latest admin sdk build?

You mentioned that by commenting out firebaseApp.auth() fixes the issue. That line of code looks like from the Firebase JS SDK to me... are you using the JS SDK in the same app?

@hiranya911
Copy link
Contributor

The error is actually thrown by one of the dependencies (jose). From node_modules/jose/lib/jwk/key/rsa.js:

// file: example.js
const { generateKeyPairSync, generateKeyPair: async } = require('crypto')
const { promisify } = require('util')
promisify(async);

You should be able to reproduce the error by just putting the above 3 lines into a file, and trying to execute it.

The root cause here is that jose requires at least Node.js v10.13.0. Anything older (e.g. v10.10.0) will result in the above error.

$ nvm use v10.10.0
Now using node v10.10.0 (npm v6.4.1)
hkj@hkj:~ $ node example.js 
internal/util.js:257
    throw new ERR_INVALID_ARG_TYPE('original', 'Function', original);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type Function. Received type undefined
    at promisify (internal/util.js:257:11)
    at Object.<anonymous> (/usr/local/google/home/hkj/example.js:4:1)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:279:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:696:3)

hkj@hkj:~ $ nvm use v10.13.0
Now using node v10.13.0 (npm v6.4.1)
hkj@hkj:~ $ node example.js
DONE

@pfinazzo you should be able to resolve the issue by upgrading your Node.js version to v10.13.0 or higher in your deployment (your local environment probably already has a newer version). I'd actually recommend upgrading all the way to Node.js v12 since v10 has EoL'ed, and no longer recommended for production deployments.

@lahirumaramba we should probably update the Node.js requirement in our package.json file (and may be also file a bug against jose).

@hiranya911
Copy link
Contributor

P.S. Actually Jose's Node.js requirement is pretty well documented: https://github.com/panva/jose/tree/v2.0.5#usage (so that's WAI).

@pfinazzo
Copy link
Author

pfinazzo commented May 26, 2021

Hi thank you so much for your replies @hiranya911 and @lahirumaramba, I will try upgrading my node version on my heroku server to see if it resolves it! I had tried upgrading my firebase-admin package, to the latest version (9.8.0) package, but my guess is @hiranya911 is right and I need to upgrade my node! thanks again for your help!

@pfinazzo
Copy link
Author

@lahirumaramba I was using the .auth() method from firebase-admin npm package

https://firebase.google.com/docs/reference/admin/node/admin.auth

@lahirumaramba
Copy link
Member

Updated the Node.js requirement in our package.json. The changes are now released with Admin SDK v9.9.0.
@pfinazzo: Thank you for letting us know about this issue! Upgrading your node environment to 10.13.0 or higher should fix this. Please let us know if you run into further issues. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants