Extension host hangs forever in `process.exit` after app quit (macOS): orphan keeps its listening port
Describe the bug
After I quit the GitHub Copilot app, one extension host process did not exit. Its parent CLI process was force-stopped by the app, the bootstrap watchdog in extension_bootstrap.mjs then called process.exit(0), and that call never returned. The main thread is blocked in uv_thread_join inside libuv's threadpool cleanup, while all four libuv worker threads sit idle in uv_cond_wait. The process uses 0% CPU, has PPID 1, and still holds its listening TCP socket.
The extension was a canvas extension that serves a local dashboard on 127.0.0.1:7927. Because the orphan still owns that port but its event loop is dead, the canvas fails to open on every later app launch:
RPC error -32603: Request session.canvas.open failed with message: Port 7927 is in use and not answering. Stop that program, or set SWARM_DASHBOARD_PORT to a free port for the Copilot app and restart it.
The extension code does not call process.exit; the exit came from the runtime's bootstrap watchdog. The hang is inside Node/libuv shutdown in the embedded runtime. The app's shutdown also has a gap: it force-stopped the host's parent, logged survivors=0, and never checked or signalled the extension host itself.
I have seen this once. The other extension hosts that were running at the same quit exited normally.
Affected version
- GitHub Copilot app 1.4.2 (commit
aa666576), macOS arm64 - Embedded runtime
copilot-sdk-runtime-1.0.106-8.unstable.r43566476370.g869eef3: Node v24.22.1, libuv 1.52.1 - Runtime image
LC_UUID 6CAF9C5B-1E60-382D-B33C-06521A6AEB0F - macOS 27.2.1 (26B131)
Steps to reproduce the behavior
I can't reproduce this on demand. What happened:
- The app was running with a session whose canvas extension (the
swarm-dashboardcanvas from thewintermuteplugin) served HTTP and SSE on127.0.0.1:7927. Its extension host was pid 80226, started 2026-11-18 13:14:15 UTC. Its parent CLI was pid 75796. - About 20 hours later I quit the app at 2026-11-19 09:19:22 UTC.
- The app force-stopped CLI pid 75796. Within about a second the bootstrap watchdog in pid 80226 saw the parent was gone and called
process.exit(0). - Pid 80226 never exited.
psshows PPID 1, stateSand 0.0% CPU. Its CPU time was21:33.95at 09:38 UTC and was still21:33.95at 09:56 UTC, about 37 minutes after the quit. - On the next app launch, opening the canvas failed with the error above, because pid 80226 still holds the
LISTENsocket on port 7927.
Expected behavior
process.exit(0)in an extension host ends the process.- If a host does not exit, the app should not leave it running after quit. An orphaned host should never keep holding ports or other resources for the next app launch.
Additional context
Main-thread stack (from sample, identical at 09:26:27 and 09:38:11 UTC)
+ 2601 node::Environment::RunTimers(uv_timer_s*) (in copilot) + 536 [0x102190120]
+ 2601 v8::Function::Call(v8::Isolate*, v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) (in copilot) + 492 [0x1024d2754]
+ 2601 ??? (in copilot) load address 0x1020e4000 + 0x579dd0 [0x10265ddd0]
+ 2601 ??? (in copilot) load address 0x1020e4000 + 0x57a46c [0x10265e46c]
+ 2601 ??? (in copilot) load address 0x1020e4000 + 0x105e570 [0x103142570]
+ 2601 ??? (in copilot) load address 0x1020e4000 + 0x105e8cc [0x1031428cc]
+ 2601 ??? (in <unknown binary>) [0x12b07c070]
+ 2601 ??? (in <unknown binary>) [0x12afc29a8]
+ 2601 ??? (in copilot) load address 0x1020e4000 + 0x10616e0 [0x1031456e0]
+ 2601 ??? (in copilot) load address 0x1020e4000 + 0x1060bec [0x103144bec]
+ 2601 ??? (in copilot) load address 0x1020e4000 + 0x1062818 [0x103146818]
+ 2601 node::Environment::Exit(node::ExitCode) (in copilot) + 392 [0x102191cbc]
+ 2601 node::DefaultProcessExitHandlerInternal(node::Environment*, node::ExitCode) (in copilot) + 68 [0x1020fb9cc]
+ 2601 ??? (in copilot) load address 0x1020e4000 + 0x103ac34 [0x10311ec34]
+ 2601 uv_thread_join (in copilot) + 20 [0x103131934]
+ 2601 _pthread_join (in libsystem_pthread.dylib) + 620 [0x19eb56fd8]
+ 2601 __ulock_wait (in libsystem_kernel.dylib) + 8 [0x19eb11af4]
All four libuv-worker threads:
2601 Thread_12128792: libuv-worker
+ 2601 thread_start (in libsystem_pthread.dylib) + 8 [0x19eb4fcd0]
+ 2601 _pthread_start (in libsystem_pthread.dylib) + 136 [0x19eb54ce4]
+ 2601 ??? (in copilot) load address 0x1020e4000 + 0x103b4a4 [0x10311f4a4]
+ 2601 uv_cond_wait (in copilot) + 40 [0x1031320a0]
+ 2601 _pthread_cond_wait (in libsystem_pthread.dylib) + 980 [0x19eb551b4]
+ 2601 __psynch_cvwait (in libsystem_kernel.dylib) + 8 [0x19eb1350c]
(Threads 12128793, 12128794 and 12128795 are the same.)
What the unnamed frames are
atos names the two unnamed offsets _uv_barrier_destroy +0x11c and _uv_cancel +0x304, but those are only the nearest exported symbols. Disassembly of the runtime binary (same LC_UUID as the live image) shows:
| Frame | Real location |
|---|---|
DefaultProcessExitHandlerInternal + 68 |
Return address of bl _uv_library_shutdown (uv_library_shutdown ends with a tail call, so it has no frame) |
+ 0x103ac34 |
Inside uv__threadpool_cleanup: return address of bl _uv_thread_join in the for (i = 0; i < nthreads; i++) join loop |
+ 0x103b4a4 |
Inside libuv's worker(): return address of bl _uv_cond_wait, in the idle wait between idle_threads += 1 and idle_threads -= 1 |
The code just before the join loop locks the threadpool mutex, queues exit_message, calls uv_cond_signal if idle_threads != 0, and unlocks. So the main thread posted the exit message and then blocked joining a worker, and no worker woke up. This matches libuv 1.52.1 src/threadpool.c (uv__threadpool_cleanup, post, worker) and Node v24.22.1 src/api/environment.cc (DefaultProcessExitHandlerInternal).
The watchdog that called process.exit
preloads/extension_bootstrap.mjs, lines 27-38:
const parentWatch = setInterval(() => {
try {
if (process.ppid !== parentPid) {
process.exit(0);
}
if (!sandboxed) {
process.kill(parentPid, 0);
}
} catch {
process.exit(0);
}
}, 1000);
The sample shows a timer callback (RunTimers → JS) calling Environment::Exit. The JS frames have no names, so the sample alone can't name the timer. This watchdog is the only timer I found that calls process.exit; the extension's own code has no process.exit, reallyExit or abort.
App log at quit (github-app.<pid>.log, owning app pid 72566)
2026-11-18T13:12:13.727933Z INFO ... github_copilot_sdk: copilot CLI client ready pid=Some(75796)
2026-11-19T09:19:22.541748Z INFO github_app::session::manager::process_teardown: terminated agent processes owned by ending sessions scope="app_exit" session_count=23 runtime_outcome="parallel" runtime_cancelled=0 verified=0 already_gone=700 unverified=4 force_killed=0 survivors=0
2026-11-19T09:19:22.633731Z INFO github_copilot_sdk: force-stopping CLI process pid=Some(75796)
No line in that log mentions pid 80226. The app does not seem to log extension hosts by pid.
System log at quit (UTC)
2026-11-19 09:19:22.630 Df analyticsd[495:f3e317] [com.apple.xpc:connection] [0x7865268a00] invalidated because the client process (pid 75796) either cancelled the connection or exited
2026-11-19 09:19:23.234 I loginwindow[439:f3eba4] [com.apple.launchservices:quitsupport] applicationDeath: app=0x0-0x13d63d5 "GitHub Copilot", has non-application coalition pids [ ... 80218/copilot, 80219/copilot, 80221/copilot, 80224/copilot, 80225/copilot, 80226/copilot, ... ], so this application stays in the running list.
That list has 64 pids. When I checked afterwards, 80226 was the only one still alive.
Other details
lsofon pid 80226:TCP localhost:7927 (LISTEN)plus three accepted sockets in stateCLOSED. No database files open.lldb process attach --pid 80226is refused ("Not allowed to attach to process"). The binary uses the hardened runtime withoutget-task-allow, so I could not read the threadpool state or take a core dump.PSYNCHkernel messages: none found, but the unified log has no kernel lines for that time window at all, so this proves nothing.
Analysis and confidence
- Certain (high confidence): the host called
process.exit(0)after its parent was force-stopped. Node ranuv_library_shutdown.uv__threadpool_cleanupposted the exit message and is blocked joining a pool thread, while all four pool threads are still parked in the idleuv_cond_wait. The event loop is gone, so the socket stays open and nothing answers on it. - Not caused by the extension's code (high confidence). The dashboard extension is where it showed up because it binds a fixed port.
- Why the workers never woke: unproven. I read libuv's
postandworkercode and the compiled loop and could not find a lost-wakeup window in libuv itself: the insert and signal happen under the mutex, and a worker tests the queue under the mutex before it waits. That leaves two candidates:- A wakeup lost below libuv:
pthread_cond_signaldid not wake a blocked waiter (libpthread or the kernel's psynch code). My estimate: about 60%. - Corrupted threadpool state:
idle_threadswas 0 although four threads were waiting, orwq,condormutexwere damaged. My estimate: about 25%. Telling these apart needs the values ofidle_threads,wqandexit_messagefrom a debugger.
- A wakeup lost below libuv:
- An unrelated project reports the same stack on macOS with Node 22 and 24, also unsolved: mhismail3/tron#729 and mhismail3/tron#1120. libuv also already works around an older Apple condition-variable bug (libuv/libuv#4165), so that layer has had defects before; that does not prove the same cause here.
- Possibly related, different trigger: github/copilot-cli#4468 (
--server --stdionever releases extension-host processes).
Asks
- Runtime / Node shutdown hang. Please look into the
process.exithang inuv__threadpool_cleanupon macOS in the embedded Node v24.22.1 / libuv 1.52.1. Whatever its root cause, the watchdog's last resort isprocess.exit, which runs Node's full teardown with no time limit, and a JS timer can't recover once the main thread blocks. When the parent is gone, the host could end without Node's teardown (for example a self-SIGKILL, or a native exit with a deadline). - App robustness on quit. The app should make sure extension hosts are actually dead on quit, not only their parent CLI: for example send
SIGKILLafter a grace period, or kill the whole process group, and then verify. Today the app logssurvivors=0while an extension host it started is still alive, so a hung exit leaves an orphan holding ports and other resources.
If it helps, the unslid addresses of libuv's threadpool statics in this build are: nthreads 0x10590e5c0, idle_threads 0x10590e5c4, slow_io_work_running 0x10590e5c8, threads 0x10590e5d0, exit_message 0x10590e5d8, wq 0x10590e608, cond 0x10590e638, mutex 0x10590e668 (add 0x20e4000 for this process). With a debuggable build, idle_threads == 4 with exit_message in wq would point to a lost wakeup; idle_threads == 0 would point to corrupted state.
Workaround
kill -9 <pid> of the orphaned host. A plain kill (SIGTERM) is unlikely to work: the extension installs a SIGTERM listener, so the signal goes to libuv's handler, which only queues it for an event loop that no longer runs. (Not tested.)
Attachments
All files are in this gist: https://gist.github.com/ncksol/8a29f1eda274b13daa142cf566dfa82a
Paths are redacted (home directory replaced with ~, project path with ~/<project-worktree>).
01-sample-pid80226-0926Z.txt: fullsampleoutput at 09:26:27 UTC02-sample-pid80226-0938Z.txt: fullsampleoutput at 09:38:11 UTC (same call graph)03-disasm-exit-path.txt: disassembly ofDefaultProcessExitHandlerInternal,uv_library_shutdown,uv__threadpool_cleanupandworker04-symbols.txt:atos-style names for the unnamed frames (nearest exported symbol only)05-lsof-pid80226.txt: open files and sockets of the hung host06-lldb-attach-refused.txt: the refused debugger attach07-app-log-quit.txt: app log lines at the quit08-app-log-next-launch-canvas-error.txt: the canvas open failure on the next launch09-system-log-quit.txt:analyticsdandloginwindowlines at the quit, including the full coalition pid list10-extension_bootstrap-excerpt.mjs:extension_bootstrap.mjslines 1-3811-ps-pid80226.txt:psstatus of the host about 37 minutes after the quit