-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
module: throw error when re-runing errored module jobs #58957
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,17 @@ | ||||||
// This tests that after failing to import an ESM that rejects, | ||||||
// retrying with require() still throws. | ||||||
|
||||||
'use strict'; | ||||||
const common = require('../common'); | ||||||
const assert = require('assert'); | ||||||
|
||||||
(async () => { | ||||||
await assert.rejects(import('../fixtures/es-modules/throw-error.mjs'), { | ||||||
message: 'test', | ||||||
}); | ||||||
assert.throws(() => { | ||||||
require('../fixtures/es-modules/throw-error.mjs'); | ||||||
}, { | ||||||
message: 'test', | ||||||
}); | ||||||
})().catch(common.mustNotCall()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We want to catch never-settling promises (EDIT: I've opened #58992 to enforce that at the linter level, so it's fine to land it as is, I can update the other PR once this one has landed)
Suggested change
Any reason not to use TLA/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the promise never settles the test should just fail with exit code 13. On the other hand using catch with must not call would surface unwanted rejections. If we use .mjs then we need to use createRequire() - I'd rather keep the plain require() since that's the more commonly hit path if some boilerplate is inevitable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think that's the case only for TLA, which we are not using here; you can convince yourself by adding a |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,16 @@ | ||||||
// This tests that after failing to require an ESM that throws, | ||||||
// retrying with import() still rejects. | ||||||
|
||||||
'use strict'; | ||||||
const common = require('../common'); | ||||||
const assert = require('assert'); | ||||||
|
||||||
assert.throws(() => { | ||||||
require('../fixtures/es-modules/throw-error.mjs'); | ||||||
}, { | ||||||
message: 'test', | ||||||
}); | ||||||
|
||||||
assert.rejects(import('../fixtures/es-modules/throw-error.mjs'), { | ||||||
message: 'test', | ||||||
}).catch(common.mustNotCall()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it would be interesting to validate we catch the exact value being thrown, not just one with the same message.