1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00
denoland-deno/runtime/ops
Andreu Botella 5c5f4ea1d6
fix(workers): Don't panic when a worker's parent thread stops running (#12156)
This panic could happen in the following cases:

- A non-fatal error being thrown from a worker, that doesn't terminate
  the worker's execution, but propagates to the main thread without
  being handled, and makes the main thread terminate.
- A nested worker being alive while its parent worker gets terminated.
- A race condition if the main event loop terminates the worker as part
  of its last task, but the worker doesn't fully terminate before the
  main event loop stops running.

This panic happens because a worker's event loop should have pending ops
as long as the worker isn't closed or terminated – but if an event loop
finishes running while it has living workers, its associated
`WorkerThread` structs will be dropped, closing the channels that keep
those ops pending.

This change adds a `Drop` implementation to `WorkerThread`, which
terminates the worker without waiting for a response. This fixes the
panic, and makes it so nested workers are automatically terminated once
any of their ancestors is closed or terminated.

This change also refactors a worker's termination code into a
`WorkerThread::terminate()` method.

Closes #11342.

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-09-22 18:02:15 +02:00
..
web_worker fix(runtime): event loop panics in classic workers (#11756) 2021-08-18 15:19:22 +02:00
fs.rs feat(unstable): Add file locking APIs (#11746) 2021-08-24 15:21:31 +02:00
fs_events.rs chore: update dependencies (#11856) 2021-09-02 23:38:44 +02:00
http.rs refactor(ops): return BadResource errors in ResourceTable calls (#11710) 2021-08-15 13:29:19 +02:00
io.rs refactor(ops): return BadResource errors in ResourceTable calls (#11710) 2021-08-15 13:29:19 +02:00
mod.rs feat(runtime): support classic workers for internal testing (#11338) 2021-08-16 14:29:54 +02:00
os.rs feat(runtime): implement navigator.hardwareConcurrency (#11448) 2021-07-29 21:45:11 +02:00
permissions.rs feat: ffi to replace plugins (#11152) 2021-08-06 23:28:10 +02:00
process.rs chore: bump crate versions for 0.14 (#12072) 2021-09-14 15:38:35 -04:00
runtime.rs cleanup(ops): remove unused ZeroCopyBuf arg-types (#10530) 2021-05-08 14:37:42 +02:00
signal.rs fix(runtime/ops/signal.rs): Add FreeBSD signal definitions (#12084) 2021-09-21 09:16:05 -04:00
tty.rs refactor(ops): return BadResource errors in ResourceTable calls (#11710) 2021-08-15 13:29:19 +02:00
utils.rs chore: update copyright headers (#10243) 2021-04-20 14:27:36 +09:00
web_worker.rs feat(runtime): support classic workers for internal testing (#11338) 2021-08-16 14:29:54 +02:00
worker_host.rs fix(workers): Don't panic when a worker's parent thread stops running (#12156) 2021-09-22 18:02:15 +02:00