Indirectly static import cjs with error will cause an uncaughtException
Open
Nobody has claimed this yet.
confirmed-bug
module
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
Version
v20.10.0
Platform
No response
Subsystem
No response
What steps will reproduce the bug?
// ./main.mjs
process.on('uncaughtException', ()=>console.log('uncaught'));
try {
await import(`data:text/javascript,
import "data:text/javascript,console.log('before')";
import "${import.meta.url}.cjs";
`);
}
catch { console.log('caught'); }
// ./main.mjs.cjs
throw Error('abc');
How often does it reproduce? Is there a required condition?
every time
What is the expected behavior? Why is that the expected behavior?
before
caught
same with dynamic await import('./main.mjs.cjs') directly or indirectly.
also intuitive.
What do you see instead?
before
uncaught
and the wrapper dynamic import promise will be forever pending
Additional information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reproducer in main.mjs with the adjacent main.mjs.cjs file, and inspect how dynamic imports handle errors from indirectly imported CommonJS modules. The fix is done when the example prints before and caught, does not emit uncaught, and the wrapper import promise settles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100