Description
Issue description
When queries fail with Sql Server, the stack trace is pointing to TypeOrm code
Expected Behavior
The stack trace should include the call site before typeorm.
Actual Behavior
The stack trace is terminated inside of the query runner code. Callbacks are resetting the stack.
Steps to reproduce
Set up a Sql Server environment
Create a query runner and perform an invalid query.
Observe the stack trace in the thrown error.
[Nest] 93661 - 05/28/2025, 7:13:42 AM ERROR [ExceptionsHandler] QueryFailedError: Error: Cannot insert the value NULL into column 'YYY', table 'XXX'; column does not allow nulls. INSERT fails.
at (/snip/node_modules/typeorm/driver/src/driver/sqlserver/SqlServerQueryRunner.ts:277:30)
at /snip/node_modules/mssql/lib/base/request.js:440:25
at Request.userCallback (/snip/node_modules/mssql/lib/tedious/request.js:492:15)
at Request.Request.callback (/snip/node_modules/tedious/src/request.ts:379:14)
at onEndOfMessage (/snip/node_modules/tedious/src/connection.ts:3755:22)
My Environment
Dependency | Version |
---|---|
Node.js version | 20.16 |
Typescript version | 5.8.3 |
TypeORM version | 0.3.24 |
Additional Context
Related to #11271 - just SQL Server instead of MySQL. May well affect other drivers too.
Relevant Database Driver(s)
- aurora-mysql
- aurora-postgres
- better-sqlite3
- cockroachdb
- cordova
- expo
- mongodb
- mysql
- nativescript
- oracle
- postgres
- react-native
- sap
- spanner
- sqlite
- sqlite-abstract
- sqljs
- sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
Yes, I have the time, and I know how to start.