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.
28162816The module being returned from the linker function is from a different context
28172817than the parent module. Linked modules must share the same context.
28182818
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-
28252819<a id =" ERR_VM_MODULE_LINK_FAILURE " ></a >
28262820
28272821### ` ERR_VM_MODULE_LINK_FAILURE `
@@ -3296,6 +3290,17 @@ Used when a given value is out of the accepted range.
32963290
32973291The module must be successfully linked before instantiation.
32983292
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+
32993304<a id =" ERR_WORKER_UNSUPPORTED_EXTENSION " ></a >
33003305
33013306### ` 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',
16251625 'Cached data cannot be created for a module which has been evaluated' , Error ) ;
16261626E ( 'ERR_VM_MODULE_DIFFERENT_CONTEXT' ,
16271627 '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 ) ;
16301632E ( 'ERR_VM_MODULE_NOT_MODULE' ,
16311633 'Provided module is not an instance of Module' , Error ) ;
16321634E ( 'ERR_VM_MODULE_STATUS' , 'Module status %s' , Error ) ;
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ const {
3434 ERR_VM_MODULE_ALREADY_LINKED ,
3535 ERR_VM_MODULE_DIFFERENT_CONTEXT ,
3636 ERR_VM_MODULE_CANNOT_CREATE_CACHED_DATA ,
37- ERR_VM_MODULE_LINKING_ERRORED ,
37+ ERR_VM_MODULE_LINK_FAILURE ,
3838 ERR_VM_MODULE_NOT_MODULE ,
3939 ERR_VM_MODULE_STATUS ,
4040} = require ( 'internal/errors' ) . codes ;
@@ -317,9 +317,7 @@ class SourceTextModule extends Module {
317317 throw new ERR_VM_MODULE_DIFFERENT_CONTEXT ( ) ;
318318 }
319319 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 ) ;
323321 }
324322 if ( module . status === 'unlinked' ) {
325323 await module [ kLink ] ( linker ) ;
Original file line number Diff line number Diff line change @@ -139,20 +139,25 @@ async function checkLinking() {
139139 code : 'ERR_VM_MODULE_DIFFERENT_CONTEXT'
140140 } ) ;
141141
142+ const error = new Error ( ) ;
142143 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 ( ) ) ;
144147 try {
145- await erroredModule . link ( common . mustCall ( ( ) => ( { } ) ) ) ;
148+ await erroredModule . evaluate ( ) ;
146149 } catch {
147150 // ignored
148- } finally {
149- assert . strictEqual ( erroredModule . status , 'errored' ) ;
150151 }
152+ delete globalThis . error ;
153+
154+ assert . strictEqual ( erroredModule . status , 'errored' ) ;
151155
152156 const rootModule = new SourceTextModule ( 'import "errored";' ) ;
153157 await rootModule . link ( common . mustCall ( ( ) => erroredModule ) ) ;
154158 } , {
155- code : 'ERR_VM_MODULE_LINKING_ERRORED'
159+ code : 'ERR_VM_MODULE_LINK_FAILURE' ,
160+ cause : error ,
156161 } ) ;
157162}
158163
You can’t perform that action at this time.
0 commit comments