Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

SIGABRT crash during Electron process exit (ThreadSafeFunction cleanup race)

Open
#904 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
electron, node.js, playwright

Research direction

Start by reproducing the Playwright E2E teardown with multiple active PTY sessions, then trace the ThreadSafeFunction::CallJS path through Environment::RunCleanup and CleanupHandles. Done means rapidly closing Electron windows no longer produces SIGABRT crashes or macOS diagnostic reports.

Written by the indexing model from the issue text.

Description

Environment

  • node-pty version: 1.0.0 (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: Playwright E2E tests closing Electron windows

Description

When an Electron app using node-pty closes windows (or quits), macOS crash reports are generated with EXC_CRASH / SIGABRT (abort() called). The crash occurs during Node.js environment cleanup, not during normal operation. All E2E tests pass — the crash happens after test completion during window/process teardown.

This appears to be a race condition in the ThreadSafeFunction cleanup path.

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
void Napi::details::WrapVoidCallback<Napi::ThreadSafeFunction::CallJS(...)>(...)
Napi::ThreadSafeFunction::CallJS(napi_env__*, napi_value__*, void*, void*)
node::ThreadPoolWork::ScheduleWork()::'lambda'(uv_work_s*, int)::__invoke(uv_work_s*, int)
...
node::Environment::CleanupHandles()
node::Environment::RunCleanup()
node::FreeEnvironment(node::Environment*)

Analysis

The crash path shows:

  1. node::FreeEnvironment() begins tearing down the Node.js environment
  2. Environment::RunCleanup() / CleanupHandles() fires pending handle callbacks
  3. A node-pty ThreadSafeFunction::CallJS callback is invoked
  4. Inside the callback, Napi::Error::ThrowAsJavaScriptException() is called
  5. Since the environment is being destroyed, the exception cannot be handled
  6. This triggers __cxxabiv1::failed_throwstd::__terminateabort()

Reproduction

Occurs consistently (4-5 crashes per E2E test run) when Playwright closes Electron windows that have active PTY sessions. The PTY sessions are created via node-pty and attached to xterm.js terminals.

Steps:

  1. Create multiple Electron windows with PTY sessions via node-pty
  2. Close all windows rapidly (as Playwright does during E2E teardown)
  3. macOS crash reporter triggers for each affected process

Impact

  • No functional impact (all operations complete successfully before crash)
  • macOS crash report dialogs are disruptive during automated testing
  • Crash reports accumulate in ~/Library/Logs/DiagnosticReports/

Potential Fix Direction

The ThreadSafeFunction callback should check whether the environment is still alive before calling ThrowAsJavaScriptException(). Alternatively, the callback should be safely finalized/aborted during Environment::RunCleanup() before it can fire.

Dominant language
TypeScript
Stars
2k
Forks
337
Avg merge
21h 58m
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/node-pty

All issues in microsoft/node-pty

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.