1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-15 16:43:44 -05:00
denoland-deno/cli/tests/testdata/workers
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
..
bench_large_message.ts
bench_round_robin.ts
bench_startup.ts
bench_worker.ts
broadcast_channel.ts
busy_worker.js
close_race_worker.js
deno_worker.ts
drop_handle_race.js fix(workers): Don't panic when a worker's parent thread stops running (#12156) 2021-09-22 18:02:15 +02:00
dynamic_remote.ts
error.ts
event_worker.js
event_worker_scope.js
fetching_worker.js
http_worker.js
immediately_close_worker.js
message_before_close.js Don't drop messages from workers that have already been closed (#11913) 2021-09-06 11:05:02 +02:00
message_port.ts
nested_worker.js
no_permissions_worker.js
non_deno_worker.js
nonexistent_worker.out
nonexistent_worker.ts
parent_read_check_granular_worker.js
parent_read_check_worker.js
permissions_blob_local.ts
permissions_blob_local.ts.out
permissions_blob_remote.ts
permissions_blob_remote.ts.out
permissions_data_local.ts
permissions_data_local.ts.out
permissions_data_remote.ts
permissions_data_remote.ts.out
permissions_dynamic_remote.ts
permissions_dynamic_remote.ts.out
permissions_remote_remote.ts
permissions_remote_remote.ts.out
post_undefined.ts
racy_worker.js
read_check_granular_worker.js
read_check_worker.js
shared_array_buffer.ts
sibling_worker.js
static_remote.ts
test.ts
test.ts.out
test_worker.js
test_worker.ts
throwing_worker.js
worker_crypto.js
worker_error.ts
worker_error.ts.out
worker_event_handlers.js
worker_globals.ts
worker_large_message.js
worker_location.ts
worker_nested_error.ts
worker_nested_error.ts.out
worker_structured_cloning.ts
worker_types.ts
worker_unstable.ts
worker_with_top_level_await.ts