-
Notifications
You must be signed in to change notification settings - Fork 475
Open
Description
I'm currently working through the error log of our service and noticing that some errors during transactions don't have the originalError property and others do:
Example of correct error:
Expected behaviour:
Original error property to exist in the error to verify the underlying problem with the query.
For example, this is an error that originated due to a failed constraint:
{
"cause": {
"code": "EREQUEST",
"originalError": {
"info": {
"name": "ERROR",
"handlerName": "onErrorMessage",
"number": 2627,
"state": 1,
"class": 14,
"message": "Violation of PRIMARY KEY constraint 'PKSV00301'. Cannot insert duplicate key in object 'dbo.SV00301'. The duplicate key value is (241114-0216 , 1, 0001 , RAYFLORES ).",
"serverName": "SRE-GPSERVER",
"procName": "",
"lineNumber": 1
}
},
"name": "RequestError",
"number": 2627,
"lineNumber": 1,
"state": 1,
"class": 14,
"serverName": "SRE-GPSERVER",
"procName": "",
"precedingErrors": []
},
"code": "INTERNAL_SERVER_ERROR",
"name": "TRPCError",
"message": "Violation of PRIMARY KEY constr... " // (json truncated)
}Actual behaviour:
There are other errors in which the originalError property doesn't exists:
{
"cause": {
"code": "EABORT",
"name": "TransactionError"
},
"code": "INTERNAL_SERVER_ERROR",
"name": "TRPCError",
"message": "Transaction has been aborted.",
"stack": "TransactionError: Transaction has been aborted.\n at a._rollback (C:\\Use..." // (stack truncated)
}Configuration:
const sqlConfig = {
...dbCredentials,
port: 1433,
requestTimeout: 30000,
pool: {
max: env.NODE_ENV === "development" ? 1 : 3,
min: 0,
idleTimeoutMillis: 30000,
},
options: {
encrypt: false,
trustServerCertificate: true,
},
} satisfies sql.config;Software versions
- NodeJS: v21.6.2
- node-mssql: ^10.0.2
- SQL Server: Microsoft SQL Server 2019
Why is this error not being instantiated correctly? or is this error originating from within the application?
Metadata
Metadata
Assignees
Labels
No labels