Skip to content

fix(client): retry clearance as soon as a page returns from sleep - #93

Merged
cport1 merged 1 commit into
mainfrom
fix/clearance-recover-on-wake
Nov 14, 2026
Merged

cport1 merged 1 commit into
mainfrom
fix/clearance-recover-on-wake

Conversation

@cport1

@cport1 cport1 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

When a computer sleeps longer than the clearance token lasts, the browser can wake briefly in the background (for example macOS maintenance wakes), try to renew without a working network, fail, and back off. After the real wake the page waited out that backoff while protected requests were refused. In a real sleep test this took about three minutes.

Change

  • A renewal failure records whether the page was hidden or offline at the time.
  • When the page becomes visible, or the online event fires, such a failure earns one immediate retry.
  • A failure while the page is visible keeps its delay, so repeated visibility or online events still cannot drive repeated requests (the existing test for that is unchanged).
  • The online listener is removed with the session.

Tests
Five new tests in clearance-renewal.test.ts. The three behaviour tests fail on the old code; the other two guard against skipping the delay without an absence and against a leaked listener. Full client suite, typecheck, lint and build pass.

A renewal that failed while the page was hidden or offline no longer
holds its backoff once the page is visible and online again. After a
long sleep the token has expired, so waiting out that backoff left every
protected request refused for minutes. One early retry per absence; a
failure while the page is in view keeps its delay.
@cport1
cport1 merged commit e1b7501 into main Nov 14, 2026
2 checks passed
@cport1
cport1 deleted the fix/clearance-recover-on-wake branch November 14, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant