diff --git a/tests/specs/npm/worker_shutdown_during_npm_import/__test__.jsonc b/tests/specs/npm/worker_shutdown_during_npm_import/__test__.jsonc new file mode 100644 index 0000000000..0be815e7d7 --- /dev/null +++ b/tests/specs/npm/worker_shutdown_during_npm_import/__test__.jsonc @@ -0,0 +1,13 @@ +{ + "tempDir": true, + "tests": { + "with_lock": { + "args": "run -A --quiet --lock=deno.lock main.ts", + "output": "main.out" + }, + "without_lock": { + "args": "run -A --quiet main.ts", + "output": "main.out" + } + } +} diff --git a/tests/specs/npm/worker_shutdown_during_npm_import/main.out b/tests/specs/npm/worker_shutdown_during_npm_import/main.out new file mode 100644 index 0000000000..649f816afb --- /dev/null +++ b/tests/specs/npm/worker_shutdown_during_npm_import/main.out @@ -0,0 +1,4 @@ +[UNORDERED_START] +1 +2 +[UNORDERED_END] diff --git a/tests/specs/npm/worker_shutdown_during_npm_import/main.ts b/tests/specs/npm/worker_shutdown_during_npm_import/main.ts new file mode 100644 index 0000000000..068cef6b68 --- /dev/null +++ b/tests/specs/npm/worker_shutdown_during_npm_import/main.ts @@ -0,0 +1,6 @@ +new Worker(new URL("./worker1.ts", import.meta.url), { + type: "module", +}); +new Worker(new URL("./worker2.ts", import.meta.url), { + type: "module", +}); diff --git a/tests/specs/npm/worker_shutdown_during_npm_import/specifiers.ts b/tests/specs/npm/worker_shutdown_during_npm_import/specifiers.ts new file mode 100644 index 0000000000..46116f842e --- /dev/null +++ b/tests/specs/npm/worker_shutdown_during_npm_import/specifiers.ts @@ -0,0 +1,11 @@ +export default [ + "npm:chalk@4", + "npm:react@18.2", + "npm:preact@10.19", + "npm:ajv", + "npm:has", + "npm:picocolors", + "npm:@denotest/esm-basic", + "npm:@denotest/add", + "npm:@denotest/subtract", +]; diff --git a/tests/specs/npm/worker_shutdown_during_npm_import/worker1.ts b/tests/specs/npm/worker_shutdown_during_npm_import/worker1.ts new file mode 100644 index 0000000000..1acf253b64 --- /dev/null +++ b/tests/specs/npm/worker_shutdown_during_npm_import/worker1.ts @@ -0,0 +1,7 @@ +import specifiers from "./specifiers.ts"; +await new Promise((resolve) => setTimeout(() => resolve(), 20)); + +await Promise.all(specifiers.map((specifier) => import(specifier))); + +console.log(1); +self.close(); diff --git a/tests/specs/npm/worker_shutdown_during_npm_import/worker2.ts b/tests/specs/npm/worker_shutdown_during_npm_import/worker2.ts new file mode 100644 index 0000000000..7a381e9398 --- /dev/null +++ b/tests/specs/npm/worker_shutdown_during_npm_import/worker2.ts @@ -0,0 +1,7 @@ +import specifiers from "./specifiers.ts"; +// start importing, but close after waiting a short amount of time +specifiers.map((specifier) => import(specifier)); +await new Promise((resolve) => setTimeout(() => resolve(), 20)); +console.log(2); +self.close(); +console.log("WILL NOT BE PRINTED");