[client-resources] Remove terminal requests before reconnect - #24
Open
dearlordylord wants to merge 1 commit into
Open
[client-resources] Remove terminal requests before reconnect#24dearlordylord wants to merge 1 commit into
dearlordylord wants to merge 1 commit into
Conversation
dearlordylord
marked this pull request as ready for review
August 11, 2026 18:24
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.
This part is human-written; the AI disclaimer will be below later ---
Hi, I'm experimenting with finding corner-case bugs in "protocol-like" interactions in code (in this case, with formal methods) and was wondering if you'd be interested in a couple of PRs that close "hard-to-catch sleeper bugs [with very uncommon trigger schedules]". So the ones that may never come out, but if they do, debugging could be troublesome.
In this case, there's also a "non-functional" potential issue of stale requests accumulating indefinitely while the tab is open.
DISCLAIMER: Next is Sol writing, proofread and simplified/humanized. The code is Sol also, self-reviewed.
Summary
After the client reports a request as failed, do not consider that request again during reconnect. Keep the separate rate-limit retry behavior.
What goes wrong
The pending-request map stores unfinished requests. For an error that the client treats as final, the client rejected the caller's promise but left the request in this map. The entry had no automatic expiry. A later successful response could still remove it.
After reconnect, a
hellomessage starts request recovery. The client checks each pending request. Reconnect can then send the failed request again, even though the caller has already received an error.Why it happens
The success path removed the completed request. The final-error path rejected the promise but did not remove the request.
How I found it
I modeled the request lifecycle in Quint 0.31.0. The model checks one rule: after the client reports a final error, reconnect must not be able to send that request again. The old behavior violates this rule, and that sequence became the regression test.
The model covers request state and reconnect behavior. It does not cover message encoding, payloads, or timing.
flowchart LR A[Server returns an error] --> B{Is a rate-limit retry scheduled?} B -->|No| C[Report failure and remove request] B -->|Yes| D[Keep request pending] D --> E[Retry after the server delay]What this changes
Result
A request removed after a final error is not considered during reconnect. Rate-limit retries continue to work as before.