-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Labels
Description
Issue description
transactionDepth went negative
Expected Behavior
transactionDepth is never decremented more often than it was incremented
Actual Behavior
Negative transaction depth
Steps to reproduce
Nest a couple of transactions and cause a DB error (e.g. insert a bad value into a column of the wrong type)
My Environment
| Dependency | Version |
|---|---|
| Operating System | |
| Node.js version | 22.6.0 |
| Typescript version | 5.4.5 |
| TypeORM version | 0.3.20 |
Additional Context
Seen in the wild, in a situation where an unhandled database error occurred deep down in a transaction stack, the transactionDepth appears to be decremented more often than it was incremented. When a new save point is attempted it will cause a syntax error due to the minus sign on the negative number.
Might be related to the changes from #10210
"err": {
"driverError": {
"length": 90,
"position": "19",
"stack": "error: syntax error at or near \"-\"\n at /app/node_modules/pg/lib/client.js:526:17\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async PostgresQueryRunner.query (/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:184:25)\n at async PostgresQueryRunner.startTransaction (/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:130:13)\n at async EntityPersistExecutor.execute (/app/node_modules/typeorm/persistence/EntityPersistExecutor.js:134:25)",
"name": "error",
"routine": "scanner_yyerror",
"code": "42601",
"type": "DatabaseError",
"line": "1180",
"severity": "ERROR",
"message": "syntax error at or near \"-\"",
"file": "scan.l"
},
"file": "scan.l",
"stack": "QueryFailedError: syntax error at or near \"-\"\n at PostgresQueryRunner.query (/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async PostgresQueryRunner.startTransaction (/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:130:13)\n at async EntityPersistExecutor.execute (/app/node_modules/typeorm/persistence/EntityPersistExecutor.js:134:25)",
"severity": "ERROR",
"position": "19",
"routine": "scanner_yyerror",
"type": "QueryFailedError",
"length": 90,
"code": "42601",
"message": "syntax error at or near \"-\"",
"line": "1180",
"query": "SAVEPOINT typeorm_-7"
}
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, but I don't know how to start. I would need guidance.
alumni and aphofstede