fix: graceful shutdown and dynamic port resolution#20
Conversation
Three bug fixes for createTerminalServer(): 1. Port 0 resolution: When called with port=0 (random OS port), the returned port was always 0 instead of the actual assigned port. Now reads the real port from wss.address() after listening. 2. Async listening: Wait for the WebSocketServer 'listening' event before reading wss.address(), ensuring the port is available. 3. Graceful shutdown: Close all WebSocket clients before killing PTY processes. Previously, killing PTYs while clients were connected caused node-pty to throw an uncatchable native C++ exception (libc++abi: terminating due to uncaught Napi::Error), which crashed the host process with SIGABRT.
a3ddcd1 to
04cfc66
Compare
|
@cursoragent please review this upcoming PR |
|
Thanks — I reviewed PR #20.
Overall: LGTM for the shutdown fix; I’d just tweak the PR text and consider the |
|
@cursoragent |
What I changed (pushed to
|
Co-authored-by: Alexander Nazarov <holiber@users.noreply.github.com>
|
@cursoragent |
Added tests + small refactors to make them reliable (pushed)I implemented unit tests for the changes and pushed them to
Verification
Commit pushed: |
Co-authored-by: Alexander Nazarov <holiber@users.noreply.github.com>
|
@cursoragent nice, merge it and make a new release! Add notes to the PRs in changelog |
Done — merged + released with changelog notes
|
Co-authored-by: Alexander Nazarov <holiber@users.noreply.github.com>


Three bug fixes for createTerminalServer():
Port 0 resolution: When called with port=0 (random OS port), the returned port was always 0 instead of the actual assigned port. Now reads the real port from wss.address() after listening.
Async listening: Wait for the WebSocketServer 'listening' event before reading wss.address(), ensuring the port is available.
Graceful shutdown: Close all WebSocket clients before killing PTY processes. Previously, killing PTYs while clients were connected caused node-pty to throw an uncatchable native C++ exception (libc++abi: terminating due to uncaught Napi::Error), which crashed the host process with SIGABRT.