In a project I'm working on, once in a while I'll get some random TypeORM error that can be tedious to troubleshoot, because the stack trace from TypeORM doesn't show the origin of error in my code. It will only show the stacktrace from the TypeORM NPM package.
Any recommendation on how to solve this?
Below is an example of such a problem that recently occurred
(node:5096) UnhandledPromiseRejectionWarning: QueryFailedError: Error: Invalid usage of the option NEXT in the FETCH statement.
at new QueryFailedError (/home/myuser/repos/somefolder/my-project/api/src/error/QueryFailedError.ts:9:9)
at /home/myuser/repos/somefolder/my-project/api/src/driver/sqlserver/SqlServerQueryRunner.ts:223:37
at /home/myuser/repos/somefolder/my-project/api/node_modules/mssql/lib/base.js:1293:25
at Request.userCallback (/home/myuser/repos/somefolder/my-project/api/node_modules/mssql/lib/tedious.js:661:15)
at Request._this.callback (/home/myuser/repos/somefolder/my-project/api/node_modules/tedious/lib/request.js:61:27)
at Connection.endOfMessageMarkerReceived (/home/myuser/repos/somefolder/my-project/api/node_modules/tedious/lib/connection.js:1944:20)
at Connection.dispatchEvent (/home/myuser/repos/somefolder/my-project/api/node_modules/tedious/lib/connection.js:1012:38)
at Parser.<anonymous> (/home/myuser/repos/somefolder/my-project/api/node_modules/tedious/lib/connection.js:812:18)
at Parser.emit (events.js:310:20)
at Parser.EventEmitter.emit (domain.js:482:12)
at Parser.<anonymous> (/home/myuser/repos/somefolder/my-project/api/node_modules/tedious/lib/token/token-stream-parser.js:54:15)
at Parser.emit (events.js:310:20)
at Parser.EventEmitter.emit (domain.js:482:12)
at addChunk (/home/myuser/repos/somefolder/my-project/api/node_modules/readable-stream/lib/_stream_readable.js:291:12)
at readableAddChunk (/home/myuser/repos/somefolder/my-project/api/node_modules/readable-stream/lib/_stream_readable.js:278:11)
at Parser.Readable.push (/home/myuser/repos/somefolder/my-project/api/node_modules/readable-stream/lib/_stream_readable.js:245:10)
You can enable logging of all queries and errors by simply setting logging: true in your connection options.
See this for more information.
Moreover you also can set different types of logging in connection options.
Enabling this functionality will show every SQL command executed by typeorm in your terminal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With