fix: isolate stateless HTTP request exchanges - #264
Open
jstar0 wants to merge 1 commit into
Open
Conversation
Signed-off-by: King Star <mcxin.y@gmail.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
Fixes #254.
StatelessHTTPServerTransportcurrently keys response waiters by the client'sraw JSON-RPC id. Because ids are scoped to each client, concurrent POSTs can
legally reuse the same id; the later request then overwrites the earlier
continuation, leaving one HTTP exchange suspended indefinitely. String and
integer ids also collide after stringification.
Changes
This change assigns a private UUID to each in-flight HTTP exchange before the
request is yielded to
Server. Responses route by that private id, then restorethe client's original string or integer id before returning over HTTP.
The same exchange identity now scopes HTTP request context, while typed raw-id
aliases preserve existing direct lookups. A package-only mapping keeps
Server.currentHandlerContext.idand cancellation lookup on the original clientid without changing public transport or handler APIs. Cancellation fails closed
when multiple active exchanges make a reused wire id ambiguous.
Verification
flight before sending either response.
cancellation compatibility coverage.
swift test -vResult: 555 tests in 40 suites passed.
Scope
are unchanged.
completion. PR fix: StatelessHTTPServerTransport leaves the original POST hanging after notifications/cancelled (#255) #260 covers that separate path and currently lists StatelessHTTPServerTransport: concurrent requests sharing a JSON-RPC id overwrite each other's response waiter (hang + continuation leak) #254 as a
non-goal; if it lands first, its raw-id waiter lookup will need to resolve the
active exchange instead.