File tree Expand file tree Collapse file tree 4 files changed +27
-17
lines changed Expand file tree Collapse file tree 4 files changed +27
-17
lines changed Original file line number Diff line number Diff line change @@ -2816,12 +2816,6 @@ Cached data cannot be created for modules which have already been evaluated.
2816
2816
The module being returned from the linker function is from a different context
2817
2817
than the parent module. Linked modules must share the same context.
2818
2818
2819
- <a id =" ERR_VM_MODULE_LINKING_ERRORED " ></a >
2820
-
2821
- ### ` ERR_VM_MODULE_LINKING_ERRORED `
2822
-
2823
- The linker function returned a module for which linking has failed.
2824
-
2825
2819
<a id =" ERR_VM_MODULE_LINK_FAILURE " ></a >
2826
2820
2827
2821
### ` ERR_VM_MODULE_LINK_FAILURE `
@@ -3296,6 +3290,17 @@ Used when a given value is out of the accepted range.
3296
3290
3297
3291
The module must be successfully linked before instantiation.
3298
3292
3293
+ <a id =" ERR_VM_MODULE_LINKING_ERRORED " ></a >
3294
+
3295
+ ### ` ERR_VM_MODULE_LINKING_ERRORED `
3296
+
3297
+ <!-- YAML
3298
+ added: v10.0.0
3299
+ removed: REPLACEME
3300
+ -->
3301
+
3302
+ The linker function returned a module for which linking has failed.
3303
+
3299
3304
<a id =" ERR_WORKER_UNSUPPORTED_EXTENSION " ></a >
3300
3305
3301
3306
### ` ERR_WORKER_UNSUPPORTED_EXTENSION `
Original file line number Diff line number Diff line change @@ -1625,8 +1625,10 @@ E('ERR_VM_MODULE_CANNOT_CREATE_CACHED_DATA',
1625
1625
'Cached data cannot be created for a module which has been evaluated' , Error ) ;
1626
1626
E ( 'ERR_VM_MODULE_DIFFERENT_CONTEXT' ,
1627
1627
'Linked modules must use the same context' , Error ) ;
1628
- E ( 'ERR_VM_MODULE_LINKING_ERRORED' ,
1629
- 'Linking has already failed for the provided module' , Error ) ;
1628
+ E ( 'ERR_VM_MODULE_LINK_FAILURE' , function ( message , cause ) {
1629
+ this . cause = cause ;
1630
+ return message ;
1631
+ } , Error ) ;
1630
1632
E ( 'ERR_VM_MODULE_NOT_MODULE' ,
1631
1633
'Provided module is not an instance of Module' , Error ) ;
1632
1634
E ( 'ERR_VM_MODULE_STATUS' , 'Module status %s' , Error ) ;
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ const {
34
34
ERR_VM_MODULE_ALREADY_LINKED ,
35
35
ERR_VM_MODULE_DIFFERENT_CONTEXT ,
36
36
ERR_VM_MODULE_CANNOT_CREATE_CACHED_DATA ,
37
- ERR_VM_MODULE_LINKING_ERRORED ,
37
+ ERR_VM_MODULE_LINK_FAILURE ,
38
38
ERR_VM_MODULE_NOT_MODULE ,
39
39
ERR_VM_MODULE_STATUS ,
40
40
} = require ( 'internal/errors' ) . codes ;
@@ -317,9 +317,7 @@ class SourceTextModule extends Module {
317
317
throw new ERR_VM_MODULE_DIFFERENT_CONTEXT ( ) ;
318
318
}
319
319
if ( module . status === 'errored' ) {
320
- // TODO(devsnek): replace with ERR_VM_MODULE_LINK_FAILURE
321
- // and error cause proposal.
322
- throw new ERR_VM_MODULE_LINKING_ERRORED ( ) ;
320
+ throw new ERR_VM_MODULE_LINK_FAILURE ( `request for '${ identifier } ' resolved to an errored module` , module . error ) ;
323
321
}
324
322
if ( module . status === 'unlinked' ) {
325
323
await module [ kLink ] ( linker ) ;
Original file line number Diff line number Diff line change @@ -139,20 +139,25 @@ async function checkLinking() {
139
139
code : 'ERR_VM_MODULE_DIFFERENT_CONTEXT'
140
140
} ) ;
141
141
142
+ const error = new Error ( ) ;
142
143
await assert . rejects ( async ( ) => {
143
- const erroredModule = new SourceTextModule ( 'import "foo";' ) ;
144
+ globalThis . error = error ;
145
+ const erroredModule = new SourceTextModule ( 'throw error;' ) ;
146
+ await erroredModule . link ( common . mustNotCall ( ) ) ;
144
147
try {
145
- await erroredModule . link ( common . mustCall ( ( ) => ( { } ) ) ) ;
148
+ await erroredModule . evaluate ( ) ;
146
149
} catch {
147
150
// ignored
148
- } finally {
149
- assert . strictEqual ( erroredModule . status , 'errored' ) ;
150
151
}
152
+ delete globalThis . error ;
153
+
154
+ assert . strictEqual ( erroredModule . status , 'errored' ) ;
151
155
152
156
const rootModule = new SourceTextModule ( 'import "errored";' ) ;
153
157
await rootModule . link ( common . mustCall ( ( ) => erroredModule ) ) ;
154
158
} , {
155
- code : 'ERR_VM_MODULE_LINKING_ERRORED'
159
+ code : 'ERR_VM_MODULE_LINK_FAILURE' ,
160
+ cause : error ,
156
161
} ) ;
157
162
}
158
163
You can’t perform that action at this time.
0 commit comments