ReviewOS

zig-utils/zig-js

ABI: reconstruct async Error stacks from Promise await chains

#254
Closed chris opened this 9 days ago ·
9 days ago

Parent: #140 Profiles: #163, #164 Roadmap: #134

Implement Bun__attachAsyncStackFromPromise from the pinned upstream algorithm, including the runtime metadata it depends on.

Acceptance:

  • Track pending Promise reaction links to suspended async-function/generator activations without retaining completed activations.
  • Retain each suspension's exact function, script, source position/byte offset, async flag, and parent result-Promise link.
  • Walk direct await and plain thenable-forwarding chains with the upstream 32-hop guard; stop at combinators, invalid links, settled promises, or the configured stack limit.
  • Attach frames only to native Error instances that have neither an existing structured trace nor materialized error info; preserve user-provided/synchronous stacks.
  • Respect selected-realm stackTraceLimit, including zero, and never replace an existing VM exception.
  • Trace all live links precisely through GC and clear them on settlement/completion so no Promise/generator graph leaks.
  • Cover nested awaits, rejection from native/event-loop code, sibling realms, empty/settled/non-Promise/null inputs, chain/hop/limit boundaries, materialized stacks, existing stacks, and GC.
  • Add the export to both inventories, the compiled fixture, API/ABI docs, README evidence, and publish zero-unclassified audit counts.

This remains separate from #253: that issue registers native Promise callbacks; this one reconstructs structured async stack metadata.

9 days ago

Implemented and published directly to main:

  • 0c5e5441 — Promise/activation metadata, precise GC handoff, per-segment 32-hop walker, Error materialization and realm-limit handling, async-function/generator coverage, compiled fixture, and both inventories
  • f9d308f5 — README/API/Home/ABI evidence and current counts
  • 0ccdad67 — presentation polish

Validation passes: focused async unit matrix 23/23, compiled private consumer 262/262, Home 263/431 implemented (168 pending), Bun core 257/421 implemented (164 pending), and both audits have zero unclassified declarations. The documented 1,540-sample benchmark remains current because this embedding-only diagnostic path is outside the measured workload.

Sign in to comment on this issue.