2020-04-09 22:15:17 +00:00
|
|
|
// See issue for details
|
|
|
|
// https://github.com/denoland/deno/issues/4080
|
|
|
|
//
|
2021-05-11 19:09:09 +00:00
|
|
|
// After first received message, this worker schedules
|
|
|
|
// [assert(), close(), assert()] ops on the same turn of microtask queue
|
|
|
|
// All tasks after close should not make it
|
2020-04-09 22:15:17 +00:00
|
|
|
|
2021-05-11 19:09:09 +00:00
|
|
|
onmessage = async function () {
|
|
|
|
let stage = 0;
|
|
|
|
await new Promise((_) => {
|
|
|
|
setTimeout(() => {
|
|
|
|
if (stage !== 0) throw "Unexpected stage";
|
|
|
|
stage = 1;
|
|
|
|
}, 50);
|
|
|
|
setTimeout(() => {
|
|
|
|
if (stage !== 1) throw "Unexpected stage";
|
|
|
|
stage = 2;
|
|
|
|
postMessage("DONE");
|
|
|
|
close();
|
|
|
|
}, 50);
|
2020-04-09 22:15:17 +00:00
|
|
|
setTimeout(() => {
|
2021-05-11 19:09:09 +00:00
|
|
|
throw "This should not be run";
|
|
|
|
}, 50);
|
2020-04-09 22:15:17 +00:00
|
|
|
});
|
2021-05-11 19:09:09 +00:00
|
|
|
};
|