Skip to content

Stack trace is truncated in MySQL query runner #11271

Closed as not planned
Closed as not planned

Description

@mukunda-

Issue description

When queries fail with MySQL, the stack trace is pointing to typeorm code

Expected Behavior

The stack trace should include the call site before typeorm.

Actual Behavior

The stack trace is terminated inside of the query runner code. Callbacks are resetting the stack.

Steps to reproduce

  1. Set up a MySQL environment
  2. Create a query runner and perform an invalid query.
  3. Observe the stack trace in the thrown error.

Image

My Environment

Dependency Version
Node.js version 20.15.1
Typescript version ^5.1.3
TypeORM version 0.3.20

Additional Context

#8785 has some related info, but I'm not sure what database they are using. They say that some of the stack issues have been fixed in 0.3.x, but I still see issues with the MySQL driver.

I had a quick look at the Postgres driver, and I see that it doesn't have callbacks in the main query function, hence that should be giving proper stack traces when it throws errors in the main stack.

The MySQL query function has two levels of stack truncation, first with a promise, second with the callback to the underlying mysql driver. When it fails with the error, the error is created in the second level, so it doesn't include the main stack.

I propose we edit the main query function to create the error in the main stack instead of the inner callback. I can submit a PR for that.

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. added a commit that references this issue on Feb 4, 2025
    b0c7f5d
  2. github-actions commented on Sep 17, 2025

    @github-actions

    TypeORM has returned to active development after recently transitioning to new leadership (see related announcement).

    As part of the new team's efforts to prioritise work on the project moving forward, it is necessary to clean up the backlog of stale issues.

    🧹 This issue is being automatically closed because it has had no activity in the last 6 months.
    If you believe this issue is still relevant, feel free to comment below and the maintainers may reopen it. Thank you for your contribution.

  3. added 3 commits that reference this issue on Feb 27, 2026
    8921bba
    b1368bd
    8be1412
  4. added this to the 1.0 milestone on Mar 9, 2026
  5. added a commit that references this issue on Mar 9, 2026
    117a055
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions