File tree 4 files changed +27
-17
lines changed
4 files changed +27
-17
lines changed Original file line number Diff line number Diff line change @@ -2853,12 +2853,6 @@ Cached data cannot be created for modules which have already been evaluated.
2853
2853
The module being returned from the linker function is from a different context
2854
2854
than the parent module. Linked modules must share the same context.
2855
2855
2856
- <a id =" ERR_VM_MODULE_LINKING_ERRORED " ></a >
2857
-
2858
- ### ` ERR_VM_MODULE_LINKING_ERRORED `
2859
-
2860
- The linker function returned a module for which linking has failed.
2861
-
2862
2856
<a id =" ERR_VM_MODULE_LINK_FAILURE " ></a >
2863
2857
2864
2858
### ` ERR_VM_MODULE_LINK_FAILURE `
@@ -3344,6 +3338,17 @@ Used when a given value is out of the accepted range.
3344
3338
3345
3339
The module must be successfully linked before instantiation.
3346
3340
3341
+ <a id =" ERR_VM_MODULE_LINKING_ERRORED " ></a >
3342
+
3343
+ ### ` ERR_VM_MODULE_LINKING_ERRORED `
3344
+
3345
+ <!-- YAML
3346
+ added: v10.0.0
3347
+ removed: REPLACEME
3348
+ -->
3349
+
3350
+ The linker function returned a module for which linking has failed.
3351
+
3347
3352
<a id =" ERR_WORKER_UNSUPPORTED_EXTENSION " ></a >
3348
3353
3349
3354
### ` ERR_WORKER_UNSUPPORTED_EXTENSION `
Original file line number Diff line number Diff line change @@ -1653,8 +1653,10 @@ E('ERR_VM_MODULE_CANNOT_CREATE_CACHED_DATA',
1653
1653
'Cached data cannot be created for a module which has been evaluated' , Error ) ;
1654
1654
E ( 'ERR_VM_MODULE_DIFFERENT_CONTEXT' ,
1655
1655
'Linked modules must use the same context' , Error ) ;
1656
- E ( 'ERR_VM_MODULE_LINKING_ERRORED' ,
1657
- 'Linking has already failed for the provided module' , Error ) ;
1656
+ E ( 'ERR_VM_MODULE_LINK_FAILURE' , function ( message , cause ) {
1657
+ this . cause = cause ;
1658
+ return message ;
1659
+ } , Error ) ;
1658
1660
E ( 'ERR_VM_MODULE_NOT_MODULE' ,
1659
1661
'Provided module is not an instance of Module' , Error ) ;
1660
1662
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