summaryrefslogtreecommitdiff
path: root/tests/testdata/run/worker_close_race.js
blob: 1da832425935babf5b451f9fde2be80ddf8a3a49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.

// https://github.com/denoland/deno/issues/11416
// Test for a race condition between a worker's `close()` and the main thread's
// `Worker.prototype.terminate()`.

const worker = new Worker(
  import.meta.resolve("../workers/close_race_worker.js"),
  { type: "module" },
);

worker.onmessage = () => {
  worker.terminate();
};