-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for process.exit for import running for worker thread
- Loading branch information
Showing
8 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { writeFileSync } from 'node:fs'; | ||
|
||
export function resolve(specifier, context, next) { | ||
writeFileSync(1, `resolve ${specifier}\n`); | ||
if (specifier === 'process-exit-module-resolve') { | ||
process.exit(42); | ||
} | ||
|
||
if (specifier === 'process-exit-module-load') { | ||
return { __proto__: null, shortCircuit: true, url: 'process-exit-on-load:///' } | ||
} | ||
return next(specifier, context); | ||
} | ||
|
||
export function load(url, context, next) { | ||
writeFileSync(1, `load ${url}\n`); | ||
if (url === 'process-exit-on-load:///') { | ||
process.exit(43); | ||
} | ||
return next(url, context); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import 'process-exit-module-load'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import 'process-exit-module-resolve'; |
12 changes: 12 additions & 0 deletions
12
test/fixtures/es-module-loaders/worker-log-fail-worker-load.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Worker } from 'worker_threads'; | ||
import { foo } from './module-named-exports.mjs'; | ||
|
||
const workerURLFailOnLoad = new URL('./worker-fail-on-load.mjs', import.meta.url); | ||
console.log(foo); | ||
|
||
// Spawn a worker that will fail to import a dependant module | ||
new Worker(workerURLFailOnLoad); | ||
|
||
process.on('exit', (code) => { | ||
console.log(`process exit code: ${code}`) | ||
}); |
12 changes: 12 additions & 0 deletions
12
test/fixtures/es-module-loaders/worker-log-fail-worker-resolve.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Worker } from 'worker_threads'; | ||
import { foo } from './module-named-exports.mjs'; | ||
|
||
const workerURLFailOnResolve = new URL('./worker-fail-on-resolve.mjs', import.meta.url); | ||
console.log(foo); | ||
|
||
// Spawn a worker that will fail to import a dependant module | ||
new Worker(workerURLFailOnResolve); | ||
|
||
process.on('exit', (code) => { | ||
console.log(`process exit code: ${code}`) | ||
}); |