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

TypeError [ERR_INVALID_REPL_INPUT]: Listeners for uncaughtException cannot be used in the REPL #3614

Closed
vladnds opened this issue Jul 29, 2021 · 3 comments

Comments

@vladnds
Copy link

vladnds commented Jul 29, 2021

[REQUIRED] Environment info

firebase-tools:

9.16.0

Platform:

Mac

[REQUIRED] Test case

https://github.com/vladnds/firebase-error-no-listeners-node-14

[REQUIRED] Steps to reproduce

  • run shell:
git clone https://github.com/vladnds/firebase-error-no-listeners-node-14.git
cd ./firebase-error-no-listeners-node-14/functions
npm install
npm run build
firebase functions:shell --project <specify you project id here>
  • try adding error handler:
process.on("uncaughtException", function(err) {
    console.error("uncaughtException");
})
  • see error:
Uncaught:
TypeError [ERR_INVALID_REPL_INPUT]: Listeners for `uncaughtException` cannot be used in the REPL
    at process.<anonymous> (repl.js:309:15)
    at process.emit (events.js:387:35)
    at _addListener (events.js:418:14)
    at process.addListener (events.js:466:10)
    at REPL7:1:9
    at Script.runInContext (vm.js:144:12)
    at REPLServer.defaultEval (repl.js:488:29)
    at bound (domain.js:416:15)
    at REPLServer.runBound [as eval] (domain.js:427:12)
    at REPLServer.onLine (repl.js:819:10)
    at REPLServer.emit (events.js:375:28)
    at REPLServer.emit (domain.js:470:12)
    at REPLServer.Interface._onLine (readline.js:364:10)
    at REPLServer.Interface._line (readline.js:700:8)
    at REPLServer.Interface._ttyWrite (readline.js:1045:14)
    at REPLServer.self._ttyWrite (repl.js:912:9) {
  code: 'ERR_INVALID_REPL_INPUT'
}

[REQUIRED] Expected behavior

Error handler should be registered, just like in raw nodejs REPL.

[REQUIRED] Actual behavior

logs
> firebase functions:shell --project replaced-my-project-id --debug
[2021-07-29T01:28:21.659Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2021-07-29T01:28:21.660Z] > authorizing via signed-in user (vlad.n@dsm.network)
[2021-07-29T01:28:21.660Z] [iam] checking project replaced-my-project-id for permissions ["firebase.projects.get"]
[2021-07-29T01:28:21.662Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[2021-07-29T01:28:21.662Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token  
 <request body omitted>
[2021-07-29T01:28:21.906Z] <<< HTTP RESPONSE 200 {"cache-control":"no-cache, no-store, max-age=0, must-revalidate","expires":"Mon, 01 Jan 1990 00:00:00 GMT","pragma":"no-cache","date":"Thu, 29 Jul 2021 01:28:21 GMT","content-type":"application/json; charset=utf-8","vary":"X-Origin, Referer, Origin,Accept-Encoding","server":"scaffolding on HTTPServer2","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}
[2021-07-29T01:28:21.953Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/replaced-my-project-id:testIamPermissions  
 {"permissions":["firebase.projects.get"]}
[2021-07-29T01:28:22.499Z] <<< [apiv2][status] GET https://firebase-public.firebaseio.com/cli.json 200
[2021-07-29T01:28:22.499Z] <<< [apiv2][body] GET https://firebase-public.firebaseio.com/cli.json {"cloudBuildErrorAfter":1594252800000,"cloudBuildWarnAfter":1590019200000,"defaultNode10After":1594252800000,"minVersion":"3.0.5","node8DeploysDisabledAfter":1613390400000,"node8RuntimeDisabledAfter":1615809600000,"node8WarnAfter":1600128000000}
[2021-07-29T01:28:22.916Z] <<< HTTP RESPONSE 200 {"content-type":"application/json; charset=UTF-8","vary":"X-Origin, Referer, Origin,Accept-Encoding","date":"Thu, 29 Jul 2021 01:28:22 GMT","server":"ESF","cache-control":"private","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","server-timing":"gfet4t7; dur=674","alt-svc":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}
[2021-07-29T01:28:22.939Z] [functions] Using node@14 from host.
[2021-07-29T01:28:22.941Z] defaultcredentials: writing to file /Users/develops/.config/firebase/vlad_n_dsm.network_application_default_credentials.json
[2021-07-29T01:28:22.944Z] DEBUG: Setting GAC to /Users/develops/.config/firebase/vlad_n_dsm.network_application_default_credentials.json
[2021-07-29T01:28:22.945Z] > refreshing access token with scopes: []
[2021-07-29T01:28:22.945Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token  
 <request body omitted>
[2021-07-29T01:28:23.090Z] <<< HTTP RESPONSE 200 {"date":"Thu, 29 Jul 2021 01:28:23 GMT","expires":"Mon, 01 Jan 1990 00:00:00 GMT","pragma":"no-cache","cache-control":"no-cache, no-store, max-age=0, must-revalidate","content-type":"application/json; charset=utf-8","vary":"X-Origin, Referer, Origin,Accept-Encoding","server":"scaffolding on HTTPServer2","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}
[2021-07-29T01:28:23.142Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/replaced-my-project-id/adminSdkConfig [none]
[2021-07-29T01:28:23.633Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/replaced-my-project-id/adminSdkConfig 200
[2021-07-29T01:28:23.634Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/replaced-my-project-id/adminSdkConfig {"projectId":"replaced-my-project-id","databaseURL":"https://replaced-my-project-id.firebaseio.com","storageBucket":"replaced-my-project-id.appspot.com","locationId":"us-central"}
[2021-07-29T01:28:23.657Z] [functions] Watching "/Users/develops/Documents/projects/issues/firebase-error-no-listeners-node-14/functions" for Cloud Functions...
[2021-07-29T01:28:23.665Z] DEBUG: [worker-pool] addWorker(~diagnostic~)
[2021-07-29T01:28:23.665Z] DEBUG: [worker-pool] Adding worker with key ~diagnostic~, total=1
[2021-07-29T01:28:23.665Z] DEBUG: [worker-pool] submitWork(triggerId=)
[2021-07-29T01:28:23.666Z] DEBUG: [worker-~diagnostic~-04390498-7ca2-4fcd-be6f-c1f131d41d67]: Assigning socketPath: /var/folders/15/2s3wtjxx18q2cshlfkwm4t180000gn/T/fire_emu_27092.sock
[2021-07-29T01:28:23.666Z] DEBUG: [worker-~diagnostic~-04390498-7ca2-4fcd-be6f-c1f131d41d67]: BUSY
[2021-07-29T01:28:23.803Z] DEBUG: [runtime-status] [27092] Functions runtime initialized. {"cwd":"/Users/develops/Documents/projects/issues/firebase-error-no-listeners-node-14/functions","node_version":"14.17.3"}
[2021-07-29T01:28:23.805Z] DEBUG: [runtime-status] [27092] Disabled runtime features: undefined
[2021-07-29T01:28:23.809Z] DEBUG: [runtime-status] [27092] Resolved module firebase-admin {"declared":true,"installed":true,"version":"9.11.0","resolution":"/Users/develops/Documents/projects/issues/firebase-error-no-listeners-node-14/functions/node_modules/firebase-admin/lib/index.js"}
[2021-07-29T01:28:23.812Z] DEBUG: [runtime-status] [27092] Resolved module firebase-functions {"declared":true,"installed":true,"version":"3.14.1","resolution":"/Users/develops/Documents/projects/issues/firebase-error-no-listeners-node-14/functions/node_modules/firebase-functions/lib/index.js"}
[2021-07-29T01:28:23.814Z] DEBUG: [runtime-status] [27092] Resolved module firebase-functions {"declared":true,"installed":true,"version":"3.14.1","resolution":"/Users/develops/Documents/projects/issues/firebase-error-no-listeners-node-14/functions/node_modules/firebase-functions/lib/index.js"}
[2021-07-29T01:28:23.816Z] DEBUG: [runtime-status] [27092] Outgoing network have been stubbed. [{"name":"http","status":"mocked"},{"name":"http","status":"mocked"},{"name":"https","status":"mocked"},{"name":"https","status":"mocked"},{"name":"net","status":"mocked"}]
[2021-07-29T01:28:23.817Z] DEBUG: [runtime-status] [27092] Resolved module firebase-functions {"declared":true,"installed":true,"version":"3.14.1","resolution":"/Users/develops/Documents/projects/issues/firebase-error-no-listeners-node-14/functions/node_modules/firebase-functions/lib/index.js"}
[2021-07-29T01:28:23.874Z] DEBUG: [runtime-status] [27092] Checked functions.config() {"config":{}}
[2021-07-29T01:28:23.874Z] DEBUG: [runtime-status] [27092] firebase-functions has been stubbed. {"functionsResolution":{"declared":true,"installed":true,"version":"3.14.1","resolution":"/Users/develops/Documents/projects/issues/firebase-error-no-listeners-node-14/functions/node_modules/firebase-functions/lib/index.js"}}
[2021-07-29T01:28:23.874Z] DEBUG: [runtime-status] [27092] Resolved module firebase-functions {"declared":true,"installed":true,"version":"3.14.1","resolution":"/Users/develops/Documents/projects/issues/firebase-error-no-listeners-node-14/functions/node_modules/firebase-functions/lib/index.js"}
[2021-07-29T01:28:23.877Z] DEBUG: [runtime-status] [27092] Resolved module firebase-admin {"declared":true,"installed":true,"version":"9.11.0","resolution":"/Users/develops/Documents/projects/issues/firebase-error-no-listeners-node-14/functions/node_modules/firebase-admin/lib/index.js"}
[2021-07-29T01:28:23.878Z] DEBUG: [runtime-status] [27092] Resolved module firebase-functions {"declared":true,"installed":true,"version":"3.14.1","resolution":"/Users/develops/Documents/projects/issues/firebase-error-no-listeners-node-14/functions/node_modules/firebase-functions/lib/index.js"}
[2021-07-29T01:28:23.878Z] DEBUG: [runtime-status] [27092] firebase-admin has been stubbed. {"adminResolution":{"declared":true,"installed":true,"version":"9.11.0","resolution":"/Users/develops/Documents/projects/issues/firebase-error-no-listeners-node-14/functions/node_modules/firebase-admin/lib/index.js"}}
[2021-07-29T01:28:23.881Z] DEBUG: [worker-~diagnostic~-04390498-7ca2-4fcd-be6f-c1f131d41d67]: IDLE
[2021-07-29T01:28:23.882Z] [functions[us-central1-helloWorld]] http function initialized (http://localhost:5001/replaced-my-project-id/us-central1/helloWorld).
i  functions: Loaded functions: helloWorld 
  functions: The following emulators are not running, calls to these services will affect production: firestore, database, pubsub, storage 
firebase > 
firebase > 
firebase > 
firebase > 
firebase > 
firebase > 
firebase > 
firebase > 
firebase > 
firebase > 
firebase > 
firebase > 
firebase > 
firebase > 
firebase > 
firebase > 
firebase > 
firebase > 
firebase > 
firebase > process.on("uncaughtException", function(err) {
...     console.error("uncaughtException");
... })
Uncaught:
TypeError [ERR_INVALID_REPL_INPUT]: Listeners for `uncaughtException` cannot be used in the REPL
    at process.<anonymous> (repl.js:309:15)
    at process.emit (events.js:387:35)
    at _addListener (events.js:418:14)
    at process.addListener (events.js:466:10)
    at REPL22:1:9
    at Script.runInContext (vm.js:144:12)
    at REPLServer.defaultEval (repl.js:488:29)
    at bound (domain.js:416:15)
    at REPLServer.runBound [as eval] (domain.js:427:12)
    at REPLServer.onLine (repl.js:819:10)
    at REPLServer.emit (events.js:375:28)
    at REPLServer.emit (domain.js:470:12)
    at REPLServer.Interface._onLine (readline.js:364:10)
    at REPLServer.Interface._line (readline.js:700:8)
    at REPLServer.Interface._ttyWrite (readline.js:1045:14)
    at REPLServer.self._ttyWrite (repl.js:912:9) {
  code: 'ERR_INVALID_REPL_INPUT'
}
firebase >

Additional Details

Questions

  • where should I search for the reason of this issue ?
    • (general node REPL doesn't have such error)
  • are there any workarounds ?
  • what can I do to help fixing it ?
@taeold taeold assigned taeold and unassigned abeisgoat Mar 7, 2022
@taeold
Copy link
Contributor

taeold commented Jan 18, 2023

Unfortunately this is due to a change in Node.js REPL implementation which the functions:shell command is built on top of.

https://nodejs.org/api/repl.html#repl_global_uncaught_exceptions

It sounds like based on your research that a "fix" was included in v13. Do you mind trying to run the command by targeting Node.js14 functions instead?

@google-oss-bot
Copy link
Contributor

Hey @vladnds. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@google-oss-bot
Copy link
Contributor

Since there haven't been any recent updates here, I am going to close this issue.

@vladnds if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

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

No branches or pull requests

4 participants