Repository navigation
fix: support the msnodesqlv8 5.6 error, cancel and info events - #1917
Merged
Merged
Conversation
This was referenced Oct 12, 2026
dhensby
commented
Oct 12, 2026
msnodesqlv8 5.6 reports an error that does not end the batch with more=true and carries on to 'done', where earlier versions ended the batch on it with more=false. A request only failed on a more=false error, so under 5.6 these requests resolved: executing a procedure that does not exist, a RAISERROR followed by results, a prepared statement that fails to prepare. A request now fails in 'done' when errors were collected on the way, as it does on tedious. Streams are unchanged: they emit each error as it arrives. The msnodesqlv8 driver only runs on Windows CI, so the new unit tests stand a stub in for it and play the events each version emits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A failed msnodesqlv8 request kept only the error just before the last one in `precedingErrors`. msnodesqlv8 5.6 carries a batch on after an error, so a batch can now report several, and the earlier ones were lost. Keep them all, as tedious does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a statement is terminated, SQL Server follows its error with 3621 "The statement has been terminated.". msnodesqlv8 5.6 emits that message ahead of the error, and the request failed with the 3621 instead of the error that caused it, such as 2627 for a duplicate key. The message now settles the request only when the error came with it in the same diagnostics, which msnodesqlv8 2.0 needs because it can stop after the message. Otherwise the error that follows, or 'done', settles the request. A stream no longer emits that error a second time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dhensby
force-pushed
the
fix/msnodesqlv8-5.6-events
branch
from
October 12, 2026 15:36
ed5a60e to
cd7cce4
Compare
There was a problem hiding this comment.
🟡 Changes recommended
A cancel-generated done can release a connection while the driver is still using it, allowing unsafe concurrent reuse.
2 open findings
What changed in this PR
Adapts the msnodesqlv8 adapter to version 5.6 event ordering and cancellation behavior.
Changes:
- Preserves and reports batch errors correctly.
- Reports cancellations as
ECANCEL. - Adds event-stub and integration coverage plus documentation updates.
| File | Description |
|---|---|
lib/msnodesqlv8/request.js |
Handles revised error, info, and cancellation events. |
test/common/unit.js |
Adds msnodesqlv8 event-stub tests. |
test/common/tests.js |
Adds shared error and cancellation integration tests. |
test/msnodesqlv8/msnodesqlv8.js |
Enables version-aware msnodesqlv8 tests. |
test/tedious/tedious.js |
Runs new shared tests against tedious. |
README.md |
Documents cancellation behavior. |
.github/workflows/nodejs.yml |
Corrects the prebuild compatibility note. |
.github/copilot-instructions.md |
Documents the event-stub testing convention. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… as ECANCEL msnodesqlv8 ends a cancelled query with 'done': a paused one in every version, and from 5.6 a running one too, followed by an 'Operation canceled' error. The request took that 'done' for success, so a cancelled request resolved with what had been read so far, and on 5.6 a stream went on to emit the late error after 'done'. A cancel is now reported as ECANCEL, as on tedious: a stream emits it as an error and then completes with what was read. The late error is dropped, and nothing msnodesqlv8 emits after 'done' reaches the request, though a broken link still marks the connection. Before 5.6 msnodesqlv8 refuses to cancel a running query that is not paused, which runs to the end as it did before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The note above the msnodesqlv8 v5 steps said upstream only builds prebuilds for Node 22, 24 and 26, so a floating `^5` could never load on Node 20 again. From 5.3.0 msnodesqlv8 ships a single Node-API binary instead of one per ABI, which may well load on Node 20; it has not been tried here, so Node 20 stays on 5.2.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dhensby
force-pushed
the
fix/msnodesqlv8-5.6-events
branch
from
October 13, 2026 09:56
4bf8e71 to
fc26723
Compare
dhensby
added a commit
to dhensby/node-mssql
that referenced
this pull request
Oct 13, 2026
Leave a cancelled request to its driver when its stream is destroyed. Since tediousjs#1917 msnodesqlv8 reports a cancelled stream with an ECANCEL error after the query is gone and its connection released; resuming the request then made msnodesqlv8 read the freed statement, emitting a 'cannot call dead statement' / 'Statement not found' error and extra 'done' and 'free' events on a connection already back in the pool. tedious resumes a cancelled request itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🎉 This PR is included in version 12.7.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.


What this does:
msnodesqlv8 5.6.0 (2026-10-11) changed how errors, cancels and info messages reach event consumers. The floating
msnodesqlv8@^5CI step turned master red the next day, in run 38225080240, with no change to our code. The failures were all 16 Windows Node 22/24 jobs, and only themsnodesqlv8 v5step.setup-sqlserver had no part in it. Its SHA, Native Client and SQL Server builds were the same in the green and the red run, and the tedious and
msnodesqlv8@^4steps passed in the same jobs.The CI failures pointed at real bugs for anyone installing msnodesqlv8 today.
Each commit fixes one of them:
fix: reject msnodesqlv8 requests whose errors do not end the batchmore=trueand the query carries on to'done'(fix: prints, errors and results after a failed statement in a batch were lost TimelordUK/node-sqlserver-v8#475). The adapter only failed on amore=falseerror, so these requests resolved:execute()of a missing procedure, RAISERROR followed by results, and a PreparedStatement whose prepare fails.'done'when errors were collected, as on tedious.require('msnodesqlv8')and play the events each version emits, so this logic is tested on every CI job and locally, not just on Windows.fix: keep every preceding error on msnodesqlv8 requests:precedingErrorskept only one earlier error. Batches now report several, so all are kept, as on tedious.fix: reject a terminated msnodesqlv8 statement with its own errorerr.numberchecks.fix: report cancelled msnodesqlv8 requests, including paused streams, as ECANCEL'done'as soon as the cancel is through, then a lateHY008 Operation cancelederror.'done'as success. So a cancelled request resolved with partial results, and a stream emitted anEREQUESTafter'done'.ECANCEL. Streams get an'error'and then'done'with what was read, as on tedious; this also covers a paused stream on any msnodesqlv8 version.'done'is ignored, but an08S01still marks the connection.ci: correct the note on msnodesqlv8 v5 prebuilds: the note claimed^5could never load on Node 20 again; since 5.3.0 msnodesqlv8 ships a single Node-API binary. This commit only changes the comment.msnodesqlv8@^5, so CI meets each new release when users do. That is how 5.6.0 was caught.Behaviour change to note:
'done'. On every msnodesqlv8 version it now emits'error'(ECANCEL) first, which matches tedious and the README.pipe()/toReadableStream()consumers without an error listener will now see that error, as they already do on tedious.Known limits: these can't be fixed in the adapter and have been reported upstream in TimelordUK/node-sqlserver-v8#479.
'done'and success, so it is reported here asECANCEL.ECANCEL.Testing:
user defined types, which always fails there because SQL Edge has no CLR.after allhook, now fails fast.ECANCELon 5.6 and a completed query before it.Related issues:
Upstream reports for the 5.6.0 behaviour:
'done'is emitted before the query has ended, and also when nothing was cancelled.The other change, TimelordUK/node-sqlserver-v8#475 (an error that does not end the batch arrives with
more=true, then'done'), was not reported. It is intended and documented: the v5.6.0 release notes call it "the main thing to warn about". Commit 1 adapts to it.Pre/Post merge checklist:
🤖 Generated with Claude Code