forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: panic in worker when closing at top level (denoland#8510)
Fixes panic occurring in worker when "self.close()" is called at the top level, ie. worker shuts down while module evaluation promise hasn't yet resolved.
- Loading branch information
1 parent
28869a6
commit 22f951a
Showing
6 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
self.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const fixtureFile = await Deno.makeTempFile(); | ||
let prefix = "file://"; | ||
if (Deno.build.os == "windows") { | ||
prefix += "/"; | ||
} | ||
const fixtureUrl = new URL(`${prefix}${fixtureFile}`); | ||
let resolve; | ||
|
||
let p = new Promise((res) => resolve = res); | ||
|
||
await Deno.writeTextFile(fixtureUrl, `self.postMessage("hello");\n`); | ||
|
||
const workerA = new Worker(fixtureUrl.href, { type: "module" }); | ||
workerA.onmessage = (msg) => { | ||
console.log(msg.data); | ||
resolve(); | ||
}; | ||
|
||
await p; | ||
workerA.terminate(); | ||
|
||
p = new Promise((res) => resolve = res); | ||
|
||
await Deno.writeTextFile(fixtureUrl, `self.postMessage("goodbye");\n`); | ||
|
||
const workerB = new Worker(fixtureUrl.href, { type: "module" }); | ||
workerB.onmessage = (msg) => { | ||
console.log(msg.data); | ||
resolve(); | ||
}; | ||
|
||
await p; | ||
workerB.terminate(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
hello | ||
goodbye |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters