mirror of
https://github.com/denoland/deno.git
synced 2024-12-27 01:29:14 -05:00
ba799b6729
Calling `worker.terminate()` used to kill the worker's isolate and then block until the worker's thread finished. This blocks the calling thread if the worker's event loop was blocked in a sync op (as with `Deno.sleepSync`), which wasn't realized at the time, but since the worker's isolate was killed at that moment, it would not block the calling thread if the worker was in a JS endless loop. However, in #12831, in order to work around a V8 bug, worker termination was changed to first set a signal to let the worker event loop know that termination has been requested, and only kill the isolate if the event loop has not finished after 2 seconds. However, this change kept the blocking, which meant that JS endless loops in the worker now blocked the parent for 2 seconds. As it turns out, after #12831 it is fine to signal termination and even kill the worker's isolate without waiting for the thread to finish, so this change does that. However, that might leave the async ops that receive messages and control data from the worker pending after `worker.terminate()`, which leads to odd results from the op sanitizer. Therefore, we set up a `CancelHandler` to cancel those ops when the worker is terminated. |
||
---|---|---|
.. | ||
web_worker | ||
fs.rs | ||
fs_events.rs | ||
http.rs | ||
io.rs | ||
mod.rs | ||
os.rs | ||
permissions.rs | ||
process.rs | ||
runtime.rs | ||
signal.rs | ||
spawn.rs | ||
tty.rs | ||
utils.rs | ||
web_worker.rs | ||
worker_host.rs |