Repository navigation
Commit c421aaa
moc
fix(checks): stop the detached service before tmpdir cleanup in cross-reuse MCP check
Round two of the same failure. Fork preview run 35506404071 (with 14a7fd5)
failed the same check #9 with the same code:
EBUSY: resource busy or locked, rmdir '...\wf-cross-mcp-3VJDll'
The test ran 7945ms -- the full ~6.2s retry budget burned while the
directory stayed locked. Not a transient lock, so retrying cannot fix it.
Real root cause (src/main.mjs, stdio branch): when no existing service is
found, --stdio spawns a detached daemon -- spawn(process.execPath, args,
{cwd:workspace, detached:true, ...}); child.unref() -- with cwd set to the
workspace (the mkdtemp tmp dir), service.log and the database inside dataDir
(the same tmp dir). By design "the service, workers and dashboard outlive"
the chat transport, so client.close()/transport.close() only tear down the
stdio face and the daemon keeps running, holding its cwd handle plus
service.log/DB handles inside the tree. win32 refuses to rmdir a directory
tree a live process is sitting in; Linux/darwin unlink open files, which is
why local runs stay green. Layer two, from run 35506090983: transport.close()
resolving does not mean a child has fully exited, so handle release can lag
an instant even after the daemon is gone.
The codebase's own convention already stops the service first
(checks/fail-loud.check.mjs:80, checks/lifecycle.check.mjs:19): run
dist/main.mjs --stop-service --workspace <dir> --data-dir <dir> after closing
the client. Identity matches this test because its --settings file sets
workspace=dataDir=dir, the same endpoint.json the daemon registered under.
- finally: after client/transport close (still deferred-rethrow), run
--stop-service wrapped in try/catch so a stop failure cannot block rm
- keep rmWithRetry as the release-lag fallback, still failing loud when
exhausted
- rewrite the comment to the two-layer root cause with both run ids
Only checks/cross-reuse-mcp.check.mjs is touched; no src/, no dist/, no new
dependencies. Local verification: npm test exit=0, 126/126; ps confirms the
daemon spawned by the check is actually terminated by the stop-service step
(no stray wf-cross-mcp-* processes remain).1 parent 22def56 commit c421aaa
1 file changed
Lines changed: 4 additions & 3 deletions
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | | - | |
| 16 | + | |
16 | 17 | | |
0 commit comments