mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
b7c2902c97
When `worker.terminate()` is called, the spec requires that the corresponding port message queue is emptied, so no messages can be received after the call, even if they were sent from the worker before it was terminated. The spec doesn't require this of `self.close()`, and since Deno uses different channels to send messages and to notify that the worker was closed, messages might still arrive after the worker is known to be closed, which are currently being dropped. This change fixes that. The fix involves two parts: one on the JS side and one on the Rust side. The JS side was using the `#terminated` flag to keep track of whether the worker is known to be closed, without distinguishing whether further messages should be dropped or not. This PR changes that flag to an enum `#state`, which can be one of `"RUNNING"`, `"CLOSED"` or `"TERMINATED"`. The Rust side was removing the `WorkerThread` struct from the workers table when a close control was received, regardless of whether there were any messages left to read, which made any subsequent calls to `op_host_recv_message` to return `Ok(None)`, as if there were no more mesasges. This change instead waits for both a close control and for the message channel's sender to be closed before the worker thread is removed from the table. |
||
---|---|---|
.. | ||
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 | ||
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 | ||
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 |