Correctly handle cancellation in WorkerMain#105
Merged
Conversation
jjudd
approved these changes
Mar 23, 2026
Although we intended to unwrap fatal exceptions like `InterruptedException` in `CancellableTask`, we were actually throwing them outside of the underlying `Future` instead of failing the `Future`. That meant that `InterruptedException`s (and other fatal errors) floated up the call stack to the thread pool where we execute work requests, crashing the worker. Here's a detailed breakdown of what would happen: 1. `InterruptedException` is thrown inside `WorkerMain#work` 2. That failure is caught inside the `recover` call in `CancellableTask` 3. The exception is re-thrown, but because `recover` only catches non-fatal exceptions, the exception floats up 4. Eventually, it reaches the top of the call stack and the worker dies This commit fixes that issue. I've verified that Bazel acknowledges actions' being cancelled from the worker's end when these changes, and an intentional `throw new InterruptedException(???)` in `ZincRunner`, are applied.
1bcfdf6 to
23157a3
Compare
jadenPete
added a commit
that referenced
this pull request
Mar 27, 2026
Correctly handle cancellation in `WorkerMain`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Although we intended to unwrap fatal exceptions like
InterruptedExceptioninCancellableTask, we were actually throwing them outside of the underlyingFutureinstead of failing theFuture. That meant thatInterruptedExceptions (and other fatal errors) floated up the call stack to the thread pool where we execute work requests, crashing the worker.Here's a detailed breakdown of what would happen:
InterruptedExceptionis thrown insideWorkerMain#workrecovercall inCancellableTaskrecoveronly catches non-fatal exceptions, the exception floats upThis commit fixes that issue. I've verified that Bazel acknowledges actions' being cancelled from the worker's end when these changes, and an intentional
throw new InterruptedException(???)inZincRunner, are applied.