fix: propagate std.Io sleep cancellation through poll and retry loops#296
Merged
fix: propagate std.Io sleep cancellation through poll and retry loops#296
Conversation
The follow-log loop swallowed a cancelled sleep, so a stop signal that reached the io subsystem before the interrupt flag flipped left the loop busy-spinning. Propagate the cancellation as a clean exit.
std.Io cancellation is single-shot per task: a backoff-sleep that catches and discards Canceled consumes the caller's stop signal, so the next request never sees it and the retry loop runs to completion. Surface Canceled as the result instead.
Symmetric with the net retry path: a swallowed Canceled would consume the caller's stop signal so the next attempt's blocking call never sees it. Surface the cancellation by exiting the retry loop instead.
Pin three additional behaviours of the cancel-on-sleep path: late cancellation after several idle polls, that the loop doesn't latch on the prior non-cancelled returns, and that data appended just before the cancel is still flushed to the writer.
The spinner's stop_flag is the primary cancellation seam, but the loop should also bail if the io subsystem reports cancellation mid-tick rather than waiting another iteration for the flag to be set.
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.
Description
Tightens cancellation handling in three loops that drop
error.Canceledfromstd.Io.sleep.std.Iocancellation is single-shot per task: a swallowedCanceledconsumes the caller's stop signal so the next operation never sees it, leaving the loop to busy-spin (services follow-log) or run all retries to completion (HTTP and bottle download). With the fix, a cancelled sleep ends the loop with the right shape per call site - a clean break for tail-follow and bottle-retry, anerror.Canceledreturn for HTTP - so a future Ctrl-C lands when the user pressed it instead of one round-trip later.Related Issue
Notes for Reviewers