Skip to content

Async stack trace stitching #1248

Open

Description

@bnoordhuis

Example:

f()

async function f() {
    await g()
}

async function g() {
    await 42 // stack trace includes f without this line
    throw Error()
}

Prints:

Possibly unhandled promise rejection: Error
    at g (tmp/async.js:9:11)

f's stack frame is "lost", making debugging harder than it should be.

It should be possible to capture the stack in or around JS_EnqueueJob and stitch it back together in JS_ExecuteJob.

That obviously comes at some performance cost, so there should be a knob to control the length of the async stack trace, with zero meaning "off".

Up for the debate: the default setting of the knob.

The captured stack should be a rolling buffer where older entries drop off. Increase the reference count of JS functions when they're mixed into the captured stack, decrease them again when they drop off.

Activity

  1. added
    enhancement
    on Nov 25, 2025
  2. added a commit that references this issue on Nov 25, 2025
  3. andrieshiemstra commented on Nov 28, 2025

    @andrieshiemstra
    Contributor

    @bnoordhuis this would be so awesome if you manage to fix this... Thanks in advance!

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions