refactor: build every bounded wait on the Socket from one BoundedWait - #334
Open
diegolmello wants to merge 1 commit into
Open
refactor: build every bounded wait on the Socket from one BoundedWait#334diegolmello wants to merge 1 commit into
diegolmello wants to merge 1 commit into
Conversation
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.
Proposed changes
The Socket hand-rolled the same wait six times — a
settledflag, asetTimeoutdeadline, and a cleanup that removes listeners and clears the timer — inwaitForClose,reopenNow,probe,waitForOpen,ping's unanswered-reply deadline, andsend's response wait. Each copy re-derived the once-only rule, and one copy differed from the others.All six now use a single
BoundedWait: it ends exactly once (first settle, deadline, orcancel), releases whatever the wait attached before the promise settles, and clears its own timer.One behavioural difference falls out of
reopenNow. It used to assignthis.reopenPromiseonly after the promise executor returned, so anopenthat arrived synchronously inside the executor deletedreopenPromisebefore it was ever set — leaving a resolved promise installed forever and every laterreopenNowa no-op. The promise now exists before the connection is created, so the release deletes the field that was actually set. No pinned expectation changed.Steps to reproduce
tscon both projects, andoxlintpass unchanged.Tests
BoundedWaitresolves with the value it is settled withBoundedWaitrejects with the error it is failed withBoundedWaitkeeps the first settle when a second followsBoundedWaitends on its deadlineBoundedWaitdoes not reach its deadline once it is settledBoundedWaitreleases what it attached, once, when it settlesBoundedWaitreleases every release it was givenBoundedWaitleaves the promise to another settler when it is cancelled