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

Support for node's --unhandled-rejections=strict #1076

Closed
alextes opened this issue Jul 16, 2020 · 4 comments
Closed

Support for node's --unhandled-rejections=strict #1076

alextes opened this issue Jul 16, 2020 · 4 comments

Comments

@alextes
Copy link

alextes commented Jul 16, 2020

Desired Behavior

When an unhandled promise rejection occurs I'd like the process to exit. Node even explains in a warning that this is their intended future behavior, if you want that behavior now, you can pass the --unhandled-rejections=strict flag. ts-node does not appear to support it. Or maybe I misunderstand how to pass it, in which case this issue can be read as a suggestion to change the docs.

Alternatives you've considered

Compiling with tsc and running with node. Sadly stack-traces get worse and it's a bit cumbersome in development when running with docker-compose for example.

@cspotcode
Copy link
Collaborator

Duplicate of multiple other issues, for example, #1073

See also: #1074, where we are awaiting a pull request that improves documentation.

@cirosantilli
Copy link

To answer other Googlers more directly this seems to do it:

node --unhandled-rejections=strict -r ts-node/register main.ts

test main.ts program:

(async () => { throw 'asdf' })()

Related: https://stackoverflow.com/questions/54041199/how-to-pass-parameters-to-a-script-processed-by-ts-node

@cspotcode
Copy link
Collaborator

This is also mentioned in the docs: https://typestrong.org/ts-node/docs/configuration#node-flags
And there is a discussion thread which goes into even more detail: #1182

@rattrayalex
Copy link

Per the docs, an alternative syntax for the lazy:

NODE_OPTIONS='--unhandled-rejections=strict' ts-node main.ts

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

No branches or pull requests

4 participants