summaryrefslogtreecommitdiff
path: root/cli/tests/subdir/racy_worker.js
blob: 83756b791d0f2ab10b871c3fa732a480c68098d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// See issue for details
// https://github.com/denoland/deno/issues/4080
//
// After first call to `postMessage() this worker schedules
// [close(), postMessage()] ops on the same turn of microtask queue
// (because message is rather big).
// Only single `postMessage()` call should make it
// to host, ie. after calling `close()` no more code should be run.

setTimeout(() => {
  close();
}, 50);

while (true) {
  await new Promise((done) => {
    setTimeout(() => {
      postMessage({ buf: new Array(999999) });
      done();
    });
  });
}