diff options
author | Marvin Hagemeister <marvin@deno.com> | 2024-05-15 17:08:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-15 17:08:25 +0200 |
commit | e02d0faedccf4c9147d9cf82e488273bd9d4d45f (patch) | |
tree | c8ff51fa910de2f3c9041d98f8abbe5f463f48e9 /tests/unit_node/worker_threads_test.ts | |
parent | e661591e7c43c907f39dac7d2cc94efd71e57089 (diff) |
fix(node): wrong `worker_threads.terminate()` return value (#23803)
<!--
Before submitting a PR, please read
https://docs.deno.com/runtime/manual/references/contributing
1. Give the PR a descriptive title.
Examples of good title:
- fix(std/http): Fix race condition in server
- docs(console): Update docstrings
- feat(doc): Handle nested reexports
Examples of bad title:
- fix #7123
- update docs
- fix bugs
2. Ensure there is a related issue and it is referenced in the PR text.
3. Ensure there are tests that cover the changes.
4. Ensure `cargo test` passes.
5. Ensure `./tools/format.js` passes without changing files.
6. Ensure `./tools/lint.js` passes.
7. Open as a draft PR if your work is still in progress. The CI won't
run
all steps, but you can add '[ci]' to a commit message to force it to.
8. If you would like to run the benchmarks on the CI, add the 'ci-bench'
label.
-->
Fixes https://github.com/denoland/deno/issues/23801
---------
Signed-off-by: Marvin Hagemeister <marvinhagemeister50@gmail.com>
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'tests/unit_node/worker_threads_test.ts')
-rw-r--r-- | tests/unit_node/worker_threads_test.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unit_node/worker_threads_test.ts b/tests/unit_node/worker_threads_test.ts index f46d982fe..e16bc8966 100644 --- a/tests/unit_node/worker_threads_test.ts +++ b/tests/unit_node/worker_threads_test.ts @@ -517,6 +517,32 @@ Deno.test({ }); Deno.test({ + name: "[node/worker_threads] Returns terminate promise with exit code", + async fn() { + const deferred = Promise.withResolvers<void>(); + const worker = new workerThreads.Worker( + ` + import { parentPort } from "node:worker_threads"; + parentPort.postMessage("ok"); + `, + { + eval: true, + }, + ); + + worker.on("message", (data) => { + assertEquals(data, "ok"); + deferred.resolve(); + }); + + await deferred.promise; + const promise = worker.terminate(); + assertEquals(typeof promise.then, "function"); + assertEquals(await promise, 0); + }, +}); + +Deno.test({ name: "[node/worker_threads] MessagePort.on all message listeners are invoked", async fn() { |