Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error connecting to MSSQL database with clustering enabled #1669

Open
nick-w-nick opened this issue Oct 30, 2024 · 0 comments · May be fixed by #1671
Open

Error connecting to MSSQL database with clustering enabled #1669

nick-w-nick opened this issue Oct 30, 2024 · 0 comments · May be fixed by #1671

Comments

@nick-w-nick
Copy link
Contributor

nick-w-nick commented Oct 30, 2024

Software versions

  • Tedious: 18.6.1
  • SQL Server: 2019
  • Node.js: 18

Additional Libraries Used and Versions
kysely v0.27.4 (query builder)
tarn v3.0.2 (connection pooling)

Table schema
N/A

Connection configuration
Standard config using default authentication method via username and password.

Problem description
I am trying to connect to a MSSQL database that has clustering enabled, but am getting the following error:

/Users/user/Documents/service-name/node_modules/tedious/src/token/handler.ts:140
    throw new UnexpectedTokenError(this, token);
          ^
UnexpectedTokenError: Unexpected token `ENVCHANGE` in `RequestTokenHandler`
    at RequestTokenHandler.onDatabaseMirroringPartner (/Users/user/Documents/service-name/node_modules/tedious/src/token/handler.ts:140:11)

This error is not present when connecting to our other identical MSSQL databases where clustering/hadr is disabled.

The weirdest thing about this is we have other services that connect to the exact same database, but use Sequelize instead of Kysely, and they work just fine. They both use Tedious as the driver, so you would assume that they would also connect identically as well, but for some reason they do not.

We have also verified that we don't seem to have database mirroring enabled, but are somehow still getting sent a DatabaseMirroringPartner event, which is causing the unhandled exception to be thrown.

Something of note may be that it seems like it connects to the database and runs the first query, but directly after returning the result of the query it throws the unexpected token error.

Expected behavior
Query runs and returns values

Actual behavior
Query runs, returns the result then immediately crashes the process

Error message/stack trace

/Users/user/Documents/service-name/node_modules/tedious/src/token/handler.ts:140
    throw new UnexpectedTokenError(this, token);
          ^
UnexpectedTokenError: Unexpected token `ENVCHANGE` in `RequestTokenHandler`
    at RequestTokenHandler.onDatabaseMirroringPartner (/Users/user/Documents/service-name/node_modules/tedious/src/token/handler.ts:140:11)

Any other details that can be helpful
N/A

@nick-w-nick nick-w-nick linked a pull request Oct 31, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant