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

include of @salesforce/core cause swallowing of uncaught exceptions #2198

Closed
pawel-id opened this issue Feb 3, 2023 · 1 comment
Closed

Comments

@pawel-id
Copy link

pawel-id commented Feb 3, 2023

I spend some time writing and debugging a little script. I found that an import of @salesforce/core registers a handler to ‘uncaughtException’. This pollutes global scope and prevents showing uncaught exceptions and returning non zero exit code.

Sample code:

import { Org } from '@salesforce/core'
throw new Error('this should be printed to stderr and returned non zero exit code')

The above script should print an error and return 1. But it does nothing and returns 0.
It is the first import handling ‘uncaughtException’. Comment first line to get proper behaviour.

Another side effect is swallowing errors like this:

import { Org } from '@salesforce/core'
nonExistentFunction()

The above code also completes without notifying any issues.

It would be great if the module would not do this. See more information https://nodejs.org/docs/latest-v18.x/api/process.html#warning-using-uncaughtexception-correctly

@WillieRuemmele WillieRuemmele transferred this issue from forcedotcom/sfdx-core Jun 13, 2023
@mshanemc
Copy link
Contributor

duplicate #2196

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

2 participants