Cancel in-flight Tedious requests when their Effects are interrupted - #6999
Cancel in-flight Tedious requests when their Effects are interrupted#6999fubhy wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: 938d379 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Caution
This PR only adds the failing regression test; the implementation fix is still missing, so the branch cannot merge. The reproduction itself is sound, but it needs to be accompanied by the source change before approval.
Reviewed changes
This PR adds one regression test to packages/sql/mssql/test/Client.test.ts that asserts conn.cancel() is called when an in-flight Tedious request is interrupted. It does not yet modify packages/sql/mssql/src/MssqlClient.ts.
- Added a
vi.mockoftediouswith aMockConnectionwhosecancel()call count is observable. - Added
it.effect("cancels an in-flight Tedious request when interrupted", ...)that forks a long query, yields, interrupts the child fiber, and assertscancelCallsincremented.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This incremental review covered the implementation fix pushed since the prior review.
- Added the missing
Effect.callbackcleanup inpackages/sql/mssql/src/MssqlClient.ts: bothrunandrunProcedurenow returnEffect.sync(() => conn.cancel()), so interruption cancels the in-flight Tedious request before the scoped pool lease can be reused. - Updated the regression test in
packages/sql/mssql/test/Client.test.tsso the mock request stays in-flight (completeRequests = falseafter constructing the client), ensuring thecancel()call comes from the interruption cleanup path rather than from a synchronous request callback. - Added a changeset (
.changeset/cancel-tedious-requests.md) describing the bugfix.
The prior review feedback has been addressed: the implementation now wires interruption to conn.cancel() and the test verifies the cleanup path rather than coincidental callback behavior.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

Summary
Interrupting a query can return its connection to the pool while Tedious is still executing on that connection.
Important
This PR starts with focused failing reproduction tests. Add the implementation fix to this same branch; CI is expected to fail until that fix is included.
Request interruption does not cancel Tedious
Module:
mssql/MssqlClientAudit ID:
sql-adapters-ms-3Severity / confidence: high / high
What happens
Interrupting a query can return its connection to the pool while Tedious is still executing on that connection.
Why it happens
The Effect.callback bridges return no interruption canceler; conn.cancel() is called only before request execution, not when the fiber is interrupted.
Expected behavior
Interruption must stop or quarantine an in-flight request before its scoped pool lease can be reused.
Relevant implementation
These links and excerpts are pinned to audit base
c9b56ab507f224426ee8388dc450da447ec4715f.packages/sql/mssql/src/MssqlClient.ts:336-376packages/sql/mssql/src/MssqlClient.ts:378-424View problematic code at
packages/sql/mssql/src/MssqlClient.ts:336-376View exact lines on GitHub
View problematic code at
packages/sql/mssql/src/MssqlClient.ts:378-424View exact lines on GitHub
Reproduction
pnpm test --run packages/sql/mssql/test/Client.test.tsObserved failure: FAIL: interruption made no additional Tedious cancel call.
Implementation handoff
The initial reproduction tests on this branch are the regression specification for the implementation fix that should follow in this PR.
pnpm test --run packages/sql/mssql/test/Client.test.tsAudit provenance
c9b56ab507f224426ee8388dc450da447ec4715fc9b56ab507f224426ee8388dc450da447ec4715fsql-adapters-ms-3Closes EFF-436