Repository navigation
fix: report an msnodesqlv8 request timeout as ETIMEOUT - #1990
Merged
Merged
Conversation
On msnodesqlv8, a request that ran past its requestTimeout failed with the code EREQUEST and the error number 0. That is the number that msnodesqlv8 gives the ODBC error HYT00 (query timeout expired). tedious reports the same timeout with the code ETIMEOUT and no error number, and the README lists ETIMEOUT for each kind of request. An error with SQLSTATE HYT00 now has the code ETIMEOUT and no error number. It keeps the message of the driver, and its state is still HYT00. This covers query(), execute(), batch(), prepared statements, streams and the statement that bulk() uses to create a table. A TransactionError from begin, commit or rollback takes the code of the request, so it is ETIMEOUT too, as on tedious. A connection timeout (HYT01) stays EREQUEST: tedious has no error like it. msnodesqlv8's own timer on Linux with ODBC Driver 17 ends a query as cancelled, with no HYT00 error, so this change does not reach it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dhensby
marked this pull request as ready for review
November 27, 2026 23:38
|
🎉 This PR is included in version 12.8.3 🎉 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:
On msnodesqlv8, a request that runs past its
requestTimeoutfails with the codeEREQUESTand the error number0. That is what msnodesqlv8 gives the ODBC errorHYT00(query timeout expired). tedious reports the same timeout with the codeETIMEOUTand no error number, and the README listsETIMEOUTfor each kind of request, with no exception for msnodesqlv8.An error with SQLSTATE
HYT00now has the codeETIMEOUTand no error number, as on tedious. It keeps the message of the driver, and itsstateis stillHYT00.codeETIMEOUTEREQUESTETIMEOUTnumberundefined0undefinedstateundefinedHYT00HYT00messageTimeout: Request failed to complete in 1000msQuery timeout expiredQuery timeout expiredThis covers
query(),execute(),batch(), prepared statements, streams and the statement thatbulk()uses to create a table. ATransactionErrorfrombegin,commitorrollbacktakes the code of the request, so it isETIMEOUTtoo, as on tedious.Not changed:
HYT01) staysEREQUEST. tedious has no error like it.HYT00error. This change does not reach that path (see msnodesqlv8 on Linux: a request timeout frees the statement while the query may still be running #1974).Code that checks
err.code === 'EREQUEST'to find an msnodesqlv8 timeout no longer matches. Such code can checkerr.code === 'ETIMEOUT', which works on both drivers.Live results:
SQL Server 2022 Developer on an Azure Windows Server 2022 VM, with
requestTimeout: 1000andwaitfor delay '00:00:05'. I tested msnodesqlv8 2.7.0 (Node 18), 3.1.0 and 4.5.0 (Node 20), 5.6.0 (Node 22) and 6.2.2 (Node 22 and 24). I ran each one with SQL Server Native Client 11.0 (the default on Windows) and with ODBC Driver 17.query(),batch(),execute(), a prepared statement, a stream, a request in a transaction, a timeout afterraiserror, abulk()whosecreate tableis blocked by another sessionEREQUEST, number0, stateHYT00ETIMEOUT, no number, stateHYT00The results are the same on each version and each ODBC driver. tedious 19.2.2 on the same server gives
ETIMEOUTwith no number in all eight cases.npm run test-msnodesqlv8passes on all six version pairs (195 to 198 passing, 0 failing).'EREQUEST'.raiserrorcomes before the timeout, msnodesqlv8 does not report theraiserrorerror at all, on master or on this branch. tedious keeps it inprecedingErrors. This change does not affect that.Tests:
msnodesqlv8 query eventsharness):query(),execute(),batch(), a stream, a timeout after a server error that does not end the batch, and a bulk load whosecreate tabletimes out. Four existing tests that expectedEREQUESTor the number0forHYT00now expectETIMEOUT, including the transactionbegintest. One test checks thatHYT01staysEREQUEST. Ten of these fail on master.test/common/tests.jsnow check thatcodeisETIMEOUTon both drivers.npm testpasses (562 unit tests).npm run test-tediousgives 225 passing and 5 pending. Three tests fail on master too:user defined typesand the two spatial/hierarchyid bulk loads. They fail because the local server is Azure SQL Edge, which has no CLR.Related issues:
Found by an audit of
@types/mssqlagainst 12.8.1. Related to #1974, which this does not change.Pre/Post merge checklist:
🤖 Generated with Claude Code