Commit 3d89e6b
module: mark evaluation rejection in require(esm) as handled
Previously the implemention of require(esm) only converted the
rejected promise from module evaluation into an error, but the
rejected promise was still treated as a pending unhandled
rejection by the promise rejection callback, because the promise
is created by V8 internals and we don't get a chance to mark
it as handled, so the rejection incorrectly marked as unhandled
would still go through unhandled rejection handling (if no
global listener is set, the default handling would print a warning
and make the Node.js instance exit with 1).
This patch fixes it by calling into the JS promise rejection
callback to mark the evalaution rejection handled so that
it doesn't go through unhandled rejection handling.
PR-URL: #56122
Backport-PR-URL: #56927
Fixes: #56115
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Refs: #526971 parent e01dd4b commit 3d89e6bCopy full SHA for 3d89e6b
File tree
Expand file treeCollapse file tree
6 files changed
+59
-0
lines changedOpen diff view settings
Filter options
- src
- test
- es-module
- fixtures/es-modules
Expand file treeCollapse file tree
6 files changed
+59
-0
lines changedOpen diff view settings
Collapse file
+16Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
609 | 609 | |
610 | 610 | |
611 | 611 | |
| 612 | + |
| 613 | + |
| 614 | + |
| 615 | + |
| 616 | + |
| 617 | + |
| 618 | + |
| 619 | + |
| 620 | + |
| 621 | + |
| 622 | + |
| 623 | + |
| 624 | + |
| 625 | + |
| 626 | + |
| 627 | + |
612 | 628 | |
613 | 629 | |
614 | 630 | |
|
Collapse file
test/es-module/test-require-module-error-catching.js
Copy file name to clipboard+21Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
Collapse file
test/es-module/test-require-module-synchronous-rejection-handling.js
Copy file name to clipboard+13Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
Collapse file
test/fixtures/es-modules/reference-error-esm.js
Copy file name to clipboard+5Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
Collapse file
test/fixtures/es-modules/runtime-error-esm.js
Copy file name to clipboard+2Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
Collapse file
test/fixtures/es-modules/synchronous-rejection-esm.js
Copy file name to clipboard+2Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
0 commit comments