Skip to content

how to print real location in code, when the typeorm throw error #11765

Closed

Description

@dengshenkk

Issue description

I used typeorm with nestjs, when the data insert get error I don't know the typeorm real error location in nestjs service

Expected Behavior

print the error location in the code file, like sourcemap? I want to know that which file and rows and column in the error

Actual Behavior

just print like this node_modules/typeorm/persistence/src/persistence/tree/NestedSetSubjectExecutor.ts:92:38

Steps to reproduce

null

My Environment

Dependency Version
Operating System macos
Node.js version 22.0.0
Typescript version x.y.zzz
TypeORM version 0.3.26

Additional Context

No response

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.

Activity

  1. OSA413 commented on Nov 13, 2025

    @OSA413
    Collaborator

    hm, I think such errors should print the whole stack trace to the relevant services in NestJS. Can you provide more info on how your app works and where do you call the insert method and how you inject the repository? and what version of TypeORM? can you provide a minimal reproducible example of the problem?

  2. sgarner commented on Nov 13, 2025

    @sgarner
    Collaborator

    The quality of async stacktraces in Node depends on the Node version as well as how code is transpiled.

    So this might be a problem with the driver rather than TypeORM itself.

    TypeORM is mostly written with modern async/await syntax and is transpiled to ES2021 (which retains async/await) so should produce good async stacktraces.

    However if an error occurs in driver code, we're at the mercy of how that driver is implemented.

    The mysql2 driver appears to target ES2016, which will rewrite async/await as callbacks - with a corresponding reduction in stacktrace usefulness.

  3. dengshenkk commented on Nov 14, 2025

    @dengshenkk
    Author
  4. pkuczynski commented on Nov 20, 2025

    @pkuczynski
    Member

    #11273 made an attempt to fix this issue...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions