Skip to content

node-pty SIGABRT crash during Electron process exit (E2E test teardown) #92

@Asukabot0

Description

@Asukabot0

Environment

  • node-pty: via @electron/rebuild
  • Electron: 35.7.5
  • Node.js: v24 (Electron embedded, NODE_MODULE_VERSION 141)
  • OS: macOS 26.3.1 (Darwin 25.3.0), ARM64 (Apple Silicon)
  • Reproduction context: pnpm test:e2e (Playwright + Electron)

Description

When running E2E tests, macOS generates 4-5 Electron crash reports (Electron-*.ips) during test teardown. All tests pass — the crashes occur after test completion when Electron windows/processes are closing.

This is a race condition in node-pty's N-API ThreadSafeFunction cleanup during Node.js environment destruction.

Crash Stack (from macOS .ips report)

__pthread_kill
pthread_kill
abort
__abort_message
demangling_terminate_handler()
_objc_terminate()
std::__terminate(void (*)())
__cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*)
__cxa_throw
Napi::Error::ThrowAsJavaScriptException() const
Napi::ThreadSafeFunction::CallJS(napi_env__*, napi_value__*, void*, void*)
node::Environment::CleanupHandles()
node::Environment::RunCleanup()
node::FreeEnvironment(node::Environment*)

Root Cause

  1. node::FreeEnvironment() begins tearing down the Node.js environment
  2. CleanupHandles() fires pending node-pty ThreadSafeFunction callbacks
  3. Inside the callback, ThrowAsJavaScriptException() is called
  4. The environment is already being destroyed, so the exception cannot be handled
  5. This triggers failed_throwstd::__terminateabort()

Impact

  • No functional impact — all E2E tests pass, crash happens post-teardown
  • macOS crash report dialogs are disruptive during automated testing
  • Reports accumulate in ~/Library/Logs/DiagnosticReports/

Workaround

Ignore the crash reports. They do not represent application bugs.

Potential Fix Direction

  • Ensure all PTY sessions are fully killed + awaited before Electron will-quit fires in PtyRuntime.dispose()
  • Or upgrade node-pty if a version with fixed ThreadSafeFunction cleanup ordering becomes available

Upstream issue filed: microsoft/node-pty#904

First Observed

2026-03-27, E2E: 169 passed / 0 failed, 5 crash reports generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions