[BUG] N-API addon lifecycle crash — same segfault on both Bun and Node.js runtimes

Resolved 💬 4 comments Opened Feb 21, 2026 by jw409 Closed Mar 21, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code

What's Wrong?

Claude Code appears to crash through the same N-API code path on both Bun and Node.js runtimes. This suggests the root cause may be in Claude Code's native addon lifecycle rather than in Bun specifically.

Crash signatures across runtimes (from public issue data):

| Runtime | Version | Fault Address | Crash Function | Source |
|---------|---------|---------------|----------------|--------|
| Bun | v1.3.5 | 0xFFFFFFFFFFFFFFFF | napi_close_callback_scope | #21875 |
| Bun | v1.3.10 | 0xFFFFFFFFFFFFFFFF | uv__process_pipe_write_req | #27320 |
| Node.js | v22.22.0 | 0xFFFFFFFFFFFFFFFF | napi_close_callback_scope via V8 | #21875 (Feb 14 comment) |

The shared fault sentinel (0xFFFFFFFFFFFFFFFF) across two different JS engines (JSC and V8) is notable. If confirmed, this would rule out a runtime-specific bug and point to Claude Code's native .node addon.

Hypothesis (not independently verified)

Based on dump analysis published in #21875 (27 full memory dumps analyzed via WinDbg by @balandari):

  1. Main thread calls napi_remove_async_cleanup_hook — begins freeing async resources
  2. Worker threads are simultaneously inside napi_unref_threadsafe_function — still using those resources
  3. Cleanup frees/corrupts a function pointer while workers hold references -> ACCESS_VIOLATION

We have not independently reproduced this. This hypothesis is based on cross-referencing public crash data across issues. The dump analysis and cross-runtime findings were produced by @balandari in #21875.

Why this matters now

#21875 requested a Bun version bump as the fix. That happened (v1.3.5 -> v1.3.10). New crash reports on v1.3.10 with identical signatures suggest the bump was insufficient:

  • #27320: 0xFFFFFFFFFFFFFFFF (same sentinel), Bun v1.3.10, 3.5 min session
  • #26984: 0x4B750B20520 (heap address), Bun v1.3.10, 2h session

If the root cause is in the addon's cleanup ordering rather than the runtime, version bumps alone won't resolve this.

What Should Happen?

Investigation into whether the native addon's threadsafe_function cleanup is properly synchronized with worker thread lifecycle.

Related Issues

  • #21875 — 78 crashes, 27 dumps, full root cause analysis (originally framed as Bun-specific)
  • #27320 — Bun v1.3.10 still crashing, same signature
  • #26984 — Bun v1.3.10, 2h session crash
  • #24874 — Node.js 65535 args limit crash after session crash at ~80% context
  • #26057 — Native .node addon deleted from /tmp

Claude Code Version

2.1.50

Platform

Anthropic API

Operating System

Windows + WSL2 (cross-platform confirmed per #21875)

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗