Repository navigation
fix: Prevent long reconnect delays or skipped backoff after a system clock change - #80
Merged
Merged
Conversation
jsonbailey
marked this pull request as ready for review
October 19, 2026 14:21
tanderson-ld
self-requested a review
October 19, 2026 14:31
tanderson-ld
approved these changes
Oct 19, 2026
jsonbailey
pushed a commit
that referenced
this pull request
Oct 19, 2026
🤖 I have created a release *beep* *boop* --- ## [1.7.4](1.7.3...1.7.4) (2026-10-19) ### Bug Fixes * Prevent long reconnect delays or skipped backoff after a system clock change ([#80](#80)) ([edf5946](edf5946)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > **Release 1.7.4** — bumps the published version from `1.7.3` to `1.7.4` in `pyproject.toml`, `ld_eventsource/version.py`, and `.release-please-manifest.json`, and documents the release in `CHANGELOG.md`. > > The changelog entry calls out the included bug fix ([#80](#80)): reconnect backoff no longer misbehaves when the system clock jumps (avoiding excessive delays or skipped backoff). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit f7f7aa2. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
Summary
The reconnect delay, the backoff-reset window, and the time-limit error strategy measured elapsed time with the wall clock (
time.time()). A clock change during an outage could stretch the reconnect sleep by the size of the change, or skip backoff entirely.time.monotonic()for all interval arithmetic in the sync and async clients and in_TimeLimitErrorStrategy. The retry-jitter random seed still usestime.time().Note
Overview
Reconnect timing no longer follows wall-clock jumps. Sync and async SSE clients now use
time.monotonic()for reconnect sleep math, disconnect timestamps, and the backoff-reset window instead oftime.time(), so NTP or manual clock changes during an outage cannot inflate reconnect delays or incorrectly reset backoff.Time-limited error retry uses the same clock.
_TimeLimitErrorStrategymeasures elapsed retry time withtime.monotonic()as well.Tests sleep slightly past time limits on Windows (~15ms clock steps) and add cases that advance
time.time()by an hour per read while asserting reconnect delays and backoff reset behavior stay correct.Reviewed by Cursor Bugbot for commit b52853c. Bugbot is set up for automated code reviews on this repo. Configure here.