-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exceptions thrown after a worker's initial execution panic #11342
Comments
Throwing that error on the worker is not a terminal error, and so it won't close or terminate the worker. However, when the error is propagated to the main thread, the main thread will terminate. This panic seems to be caused because, when |
The same panic happens when closing a worker which has still-running child workers. The Both Chromium and Firefox (WebKit doesn't support nested workers) will terminate a nested worker when its parent worker is closed or terminated. It's hard to say whether the spec allows this, though – the fact that errors are propagated up the chain of workers, even if some of those are terminated seems to imply that a terminated worker might have living descendants. |
This was causing a panic when the `WebWorkerHandle` was dropped before the worker's event loop stopped running. This could happen due to a race condition, due to a non-fatal error in the worker propagating to the main thread and closing the process, or due to a worker being terminated while it still had living worker children. Closes denoland#11342.
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 denoland#11342.
…#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 <[email protected]>
Before denoland#12156, closing a worker which had children would cause a panic (denoland#11342 (comment)). After that PR, closing a worker will also close any child workers.
…12215) Before #12156, closing a worker which had children would cause a panic (#11342 (comment)). After that PR, closing a worker will also close any child workers.
…denoland#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 denoland#11342. Co-authored-by: Bartek Iwańczuk <[email protected]>
Re-closing this issue as the event loop has been changed pretty heavily, and a long-standing bug with promise IDs rolling over has been fixed. |
test.js
worker.js
This seems to have been introduced in #11076, and it seems to be related to some of the WPT test failures in #11338.
The text was updated successfully, but these errors were encountered: