You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SIGABRT crash during Electron process exit (ThreadSafeFunction cleanup race) #904
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.
A node-pty ThreadSafeFunction::CallJS callback is invoked
Inside the callback, Napi::Error::ThrowAsJavaScriptException() is called
Since the environment is being destroyed, the exception cannot be handled
This triggers __cxxabiv1::failed_throw → std::__terminate → abort()
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:
Create multiple Electron windows with PTY sessions via node-pty
Close all windows rapidly (as Playwright does during E2E teardown)
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.
Activity
fix(desktop): dispose open PTY sessions in before-quit handler
fix(desktop): dispose open PTY sessions in before-quit handler
fix(desktop): dispose open PTY sessions in before-quit handler
fix(desktop): dispose open PTY sessions in before-quit handler
fix(desktop): dispose open PTY sessions in before-quit handler
fix(desktop): dispose open PTY sessions in before-quit handler
fix(desktop): dispose open PTY sessions in before-quit handler
fix(desktop): dispose open PTY sessions in before-quit handler
Quit crash (SIGABRT) fix: guard pty callbacks, wait for exits, and re…