Repository navigation
Closed
Labels
good first issueGood for newcomers
Description
Issue Description
TypeORM queries doesn't return stack trace that contains all it should if there error in a query.
Expected Behavior
it('test', async () => {
await connection.query('select * foo');
});This should return stack trace up to the test
Actual Behavior
But returns this even with Error.stackTraceLimit = 200; it return stack trace like this
at QueryFailedError.TypeORMError [as constructor] (error/TypeORMError.ts:7:9)
at new QueryFailedError (error/QueryFailedError.ts:9:9)
at PostgresQueryRunner.<anonymous> (driver/postgres/PostgresQueryRunner.ts:247:19)
at step (../node_modules/typeorm/node_modules/tslib/tslib.js:143:27)
at Object.throw (../node_modules/typeorm/node_modules/tslib/tslib.js:124:57)
at rejected (../node_modules/typeorm/node_modules/tslib/tslib.js:115:69)
Steps to Reproduce
import { Connection } from 'typeorm';
describe('Stack trace not returning all it should', () => {
let connection: Connection;
beforeAll(async () => {
Error.stackTraceLimit = 200;
connection = new Connection({
type: 'postgres',
host: 'localhost',
port: 5432,
username: 'postgres',
password: 'postgres',
database: 'testdb',
entities: [],
synchronize: true,
logging: false,
});
await connection.connect();
});
afterAll(async () => {
await connection.close();
});
it('should be defined', () => {
expect(connection).toBeDefined();
});
it('test', async () => {
await connection.query('select * foo');
});
});My Environment
| Dependency | Version |
|---|---|
| Operating System | Windows 10 |
| NestJS version | 8.3.1 |
| Node.js version | 16.14.0 |
| Typescript version | 4.5.5 |
| TypeORM version | 0.2.42 |
Additional Context
Currently TypeORM version is coming from NestJS but I used it directly to produce this problem.
Relevant Database Driver(s)
| DB Type | Reproducible |
|---|---|
aurora-mysql |
no |
aurora-postgres |
no |
better-sqlite3 |
no |
cockroachdb |
no |
cordova |
no |
expo |
no |
mongodb |
no |
mysql |
no |
nativescript |
no |
oracle |
no |
postgres |
yes |
react-native |
no |
sap |
no |
sqlite |
no |
sqlite-abstract |
no |
sqljs |
no |
sqlserver |
no |
Are you willing to resolve this issue by submitting a Pull Request?
- ✖️ Yes, I have the time, and I know how to start.
- ✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
- ✖️ No, I don’t have the time, but I can support (using donations) development.
- ✅ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomers
Activity
pleerock commentedon Mar 23, 2022
Not sure if it's a bug, but anyway contributions are welcomed for this issue.
wanton7 commentedon Mar 23, 2022
Async stack trace aren't properly returned. These will be returned for unbroken async/await chains. Somewhere inside TypeORM this chain is broken. Lot harder to find problems in production coming from TypeORM if this is not fixed.
pleerock commentedon Mar 23, 2022
I can't imagine what code in TypeORM can lead to broken logging chains. If you think the problem comes from TypeORM code it's better to investigate and try to find it, otherwise... I guess this issue won't be ever resolved. Also, recommend to upgrade to 0.3.x since it outputs into
es6and clean async/await output - maybe it will solve your issue.wanton7 commentedon Mar 23, 2022
Sadly our TypeORM version is coming from @nestjs/typeorm package. Because TypeORM isn't using semantic versioning at least yet I don't we can update it without breaking that package. But will try out never version of TypeORM in separate project.
pleerock commentedon Mar 23, 2022
I'm sure nestjs team will publish a new package version with updated dependencies very soon.
Ginden commentedon Mar 23, 2022
This is well known issue with TypeORM
0.2.*Unfortunately,
new Promise, used through old code, doesn't leave nice stack traces.wanton7 commentedon Mar 23, 2022
@Ginden Thank you very much for this information!