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

Report invalid --require directly instead of via UnhandledPromiseRejectionWarning #1688

Open
Krinkle opened this issue Apr 24, 2022 · 0 comments

Comments

@Krinkle
Copy link
Member

Krinkle commented Apr 24, 2022

  • QUnit version: 2.18.2
  • Which environment are you using?: Node.js
  • How are you running QUnit?: QUnit CLI

We have a test case displays helpful error when failing to require a file in test/cli/cli-main.js which. The assertion currently ensures that the output "includes" the important subset, which is Error: Cannot find module 'does-not-exist-at-all'.

However, when running it directly (in prep for #1684) I noticed it gets there in quite an unsual manner:

(node:4519) UnhandledPromiseRejectionWarning: Error: Cannot find module 'does-not-exist-at-all'
Require stack:
- /qunit/src/cli/require-from-cwd.js
- /qunit/src/cli/run.js
- /qunit/bin/qunit.js
    at internal
    at bin/qunit
    at internal
    at bin/qunit
    at internal
(node:4519) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:4519) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This happens because /src/cli/run.js currently handles options.requires before setting up options.reporter and process.on('unhandledRejection'). I suggest we swap this around.

@Krinkle Krinkle self-assigned this Apr 24, 2022
@Krinkle Krinkle changed the title Report invalid--require directly instead of via UnhandledPromiseRejectionWarning Report invalid --require directly instead of via UnhandledPromiseRejectionWarning Apr 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant