Skip to content

Bun NAPI crash on exit: panic: NAPI FATAL ERROR: Error::New napi_create_error #32544

Closed as duplicate

Description

@mskadu

Every time opencode exits, it crashes with a Bun runtime fatal error:

panic: NAPI FATAL ERROR: Error::New napi_create_error
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

The full crash includes the Bun report URL and a macOS crash report (SIGTRAP on a Worker thread) written to ~/Library/Logs/DiagnosticReports/opencode-*.ips.

Root cause: OpenCode ships as a Bun standalone executable (Bun v1.3.14). Bun v1.3.14 has a bug where NAPI finalizer tasks crash during process exit cleanup — when Zig__GlobalObject__destructOnExit runs a final GC sweep, deferred NAPI finalizers try to create error objects through an already-partially-torn-down runtime. Related upstream Bun issue: oven-sh/bun#32144

Impact: The crash happens after all work is done — no data loss, but noisy and produces spurious crash reports.

Platform: macOS 26.5.1 (Apple Silicon), opencode v1.17.7 (Homebrew), Bun v1.3.14

Fix: Rebuild opencode with a Bun version that includes a fix for the NAPI finalizer cleanup race. Currently both opencode and Bun are at v1.3.14 — this issue can be closed once the Bun fix is released and opencode picks it up.

Activity

  1. github-actions commented on Jun 16, 2026

    @github-actions
    Contributor

    This issue does not follow our contributing guidelines.

    What needs to be fixed:

    • No issue template was used. Please use one of the three templates: Bug Report, Feature Request, or Question. Bug reports require the standard fields (Description, Steps to Reproduce, etc.).
    • The description appears to be AI-generated. We ask that issues be written in your own words describing what you actually experienced — long, AI-written analyses are not acceptable.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. mskadu commented on Jun 16, 2026

    @mskadu
    Author

    Closing as a duplicate of #31563 — same platform (macOS Apple Silicon), same embedded Bun 1.3.14, same crash-on-exit with trace trap. #31563 was filed first with more detail. The upstream Bun fix is tracked at oven-sh/bun#32144.

  3. mskadu commented on Jun 16, 2026

    @mskadu
    Author

    Closing as duplicate of #31563

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

Metadata

Metadata

Assignees

Labels

needs:complianceThis means the issue will auto-close after 2 hours.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions