Repository navigation
fix(qwp): stop cancel() and grantCredit() throwing after a query ends - #79
Open
glasstiger wants to merge 4 commits into
Open
glasstiger wants to merge 4 commits into
glasstiger wants to merge 4 commits into
Conversation
QwpEgressQuery.cancel() and grantCredit(), and the same methods of the
queryViews() handles, return promises. Once the session had handled a
query's terminal response, they threw QwpProtocolError ("QWP response
references inactive request ID") synchronously instead, before any
promise existed, so a .catch() on the result never ran. A cancel() from
an AbortSignal listener or a timer that fired after the query completed
became an uncaught exception, which ends a Node process. A session that
had failed or was closing threw its failure the same way. Node and
browsers were both affected: the fault is in the shared egress session.
- cancel() on a query that has ended resolves without sending anything,
even if its session has since failed or closed.
- grantCredit() on a query that has ended resolves without sending
anything: it is owed no credit. The amount is checked first, whatever
the query's state, and an invalid one rejects with a RangeError.
- The session's cancel(), abandon(), grantCredit() and rejectView()
never throw. A request that has left the session is a no-op, and a
failed or closed session rejects with its failure. requireActive()
and its QwpProtocolError now serve only server messages, where an
unknown request ID is a protocol fault.
Callers will notice that these methods no longer throw: each returns a
promise that resolves or rejects. grantCredit() also stops sending
CREDIT for a query whose consumer has retired while it still drains.
The methods return promises and none of the old behaviour was
documented, so this restores their contract: it is a bug fix, not a
breaking change.
Document the behaviour in the TSDoc and QWP.md, and regenerate the API
reference as CONTRIBUTING.md requires. Most generated-file changes are
TypeDoc source-link, line-number and reflection-ID refreshes.
Fixes #76
CONTRIBUTING.md counted any change to the behaviour of a published API, its wire bytes or the errors it throws as breaking, "even when the new behaviour is a fix". Ordinary bug fixes were marked breaking under it, #78 among them, and each one called for a major release: data that fits within max_buf_size no longer refused, or a promise-returning method that threw synchronously and now rejects. Define a breaking change by the API's contract instead -- what code that relies on its documentation and types has to change -- in a Breaking Changes section that the release and commit guidance both point to. A fix that brings the implementation back to its contract is a plain fix:, and its commit and pull request describe what callers will notice. The wording of an error message is not part of the contract.
glasstiger
force-pushed
the
ia_late_cancel
branch
from
November 10, 2026 17:49
a614a13 to
b387a3c
Compare
…query alone The test for control calls naming a request that has left the session made them only once no query was active, so this.active was undefined whether or not controlledQuery() compared request IDs. Dropping that comparison passed every QWP test, although session.cancel(oldId) then cancelled the query running now and session.abandon(oldId) retired it. Start the next query before those calls, and check that it is still running and that its QUERY_REQUEST is the only frame sent.
…ol calls Mutating the late-control-call fix found regressions that every QWP test still passed: - The session's control calls for a request that has left it ran only while the next query was running, so controlledQuery() could throw, or read requestId off an undefined active query, on an idle session. They now also run on an idle session, and include rejectView(). - No test gave grantCredit() a bad amount on a running query, so the check could be confined to ended queries, left to the CREDIT encoder, or relaxed to accept numeric strings. A new test checks that each bad amount rejects with RangeError, never throws synchronously, sends no frame and leaves the query running. - rejectView() on a closed or failed session, and the queryViews() controls once their session has closed, went untested.
Collaborator
Author
Review of
|
Collaborator
Author
Review of
|
This branch has not been deployed
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
Once the session had received a query's terminal response, QWP
cancel()andgrantCredit()threwQwpProtocolErrorsynchronously instead of returning a promise, even while the consumer was still reading buffered batches. A cancel inside the result loop failed with this misleading protocol error. From an abort listener or timer, the throw bypassed.catch()and could crash a Node.js process. The fix applies to both the Node.js and browser clients.Changes
queryViews()handles.RangeError.Validation
Regression tests cover completed queries, view handles, invalid credit, early consumer exit, and closed or failed sessions.
Fixes #76.