Commit d3be3da
module: fix error thrown from require(esm) hitting TLA repeatedly
This tracks the asynchronicity in the ModuleWraps when they turn out to
contain TLA after instantiation, and throw the right error
(ERR_REQUIRE_ASYNC_MODULE) when it's required again. It removes
the freezing of ModuleWraps since it's not meaningful to freeze
this when the rest of the module loader is mutable, and we
can record the asynchronicity in the ModuleWrap right after
compilation after we get a V8 upgrade that contains
v8::Module::HasTopLevelAwait() instead of searching through
the module graph repeatedly which can be slow.
PR-URL: #55520
Fixes: #55516
Refs: #52697
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>1 parent b3971bb commit d3be3daCopy full SHA for d3be3da
File tree
Expand file treeCollapse file tree
5 files changed
+40
-11
lines changedOpen diff view settings
Filter options
- lib/internal
- modules/esm
- src
- test/es-module
Expand file treeCollapse file tree
5 files changed
+40
-11
lines changedOpen diff view settings
Collapse file
+3Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1650 | 1650 | |
1651 | 1651 | |
1652 | 1652 | |
| 1653 | + |
| 1654 | + |
| 1655 | + |
1653 | 1656 | |
1654 | 1657 | |
1655 | 1658 | |
|
Collapse file
lib/internal/modules/esm/loader.js
Copy file name to clipboardExpand all lines: lib/internal/modules/esm/loader.js+4Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
23 | 23 | |
24 | 24 | |
25 | 25 | |
| 26 | + |
26 | 27 | |
27 | 28 | |
28 | 29 | |
| ||
302 | 303 | |
303 | 304 | |
304 | 305 | |
| 306 | + |
| 307 | + |
| 308 | + |
305 | 309 | |
306 | 310 | |
307 | 311 | |
|
Collapse file
lib/internal/modules/esm/module_job.js
Copy file name to clipboardExpand all lines: lib/internal/modules/esm/module_job.js+14-2Lines changed: 14 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
37 | 37 | |
38 | 38 | |
39 | 39 | |
| 40 | + |
40 | 41 | |
41 | | - |
| 42 | + |
| 43 | + |
| 44 | + |
42 | 45 | |
43 | 46 | |
44 | 47 | |
| ||
378 | 381 | |
379 | 382 | |
380 | 383 | |
381 | | - |
| 384 | + |
| 385 | + |
| 386 | + |
| 387 | + |
| 388 | + |
| 389 | + |
| 390 | + |
| 391 | + |
| 392 | + |
| 393 | + |
382 | 394 | |
383 | 395 | |
384 | 396 | |
|
Collapse file
+3-9Lines changed: 3 additions & 9 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | | - |
35 | 34 | |
36 | 35 | |
37 | 36 | |
| ||
332 | 331 | |
333 | 332 | |
334 | 333 | |
335 | | - |
336 | 334 | |
337 | 335 | |
338 | 336 | |
| ||
635 | 633 | |
636 | 634 | |
637 | 635 | |
638 | | - |
639 | | - |
640 | | - |
641 | | - |
642 | | - |
643 | | - |
644 | | - |
| 636 | + |
| 637 | + |
| 638 | + |
645 | 639 | |
646 | 640 | |
647 | 641 | |
|
Collapse file
test/es-module/test-require-module-tla-retry-require.js
Copy file name to clipboard+16Lines changed: 16 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 | + |
0 commit comments