[GH-ISSUE #4529] [GUI] Stop ends the job but not the program the job started - killTree kills a tree only on Windows #2042

Closed
opened 2026-11-04 01:56:11 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @TheHubUser4860938 on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4529

Problem: apps/host/server/timeskip.mjs:148 is named killTree, and its two branches are not equivalent.

function killTree(child) {
  try {
    if (process.platform === 'win32' && child.pid) spawnSync('taskkill', ['/PID', String(child.pid), '/T', '/F'], { windowsHide: true, stdio: 'ignore' });
    else child.kill('SIGTERM');
  } catch { /* already gone */ }
}

On Windows /T takes the whole tree with it. On Linux and macOS only the direct child - the python … cli the job spawns at line 305 / line 454, and neither spawn is detached - is signalled, so anything that program started survives, re-parented to init. The Time Skip job runs the person's revision command as exactly that kind of grandchild.

Your own test expects the tree to go on every platform: apps/host/tests/timeskip-real.test.mjs:119 polls process.kill(pid, 0) for 6 s after stop(id) and asserts the revision command (a grandchild of the job) was ended too. Measured on this box (Linux, Node 26.12.1, source checkout at commit e29f8c29, npm test in apps/host): that assertion fails, and it is deterministic, not timing - node --test tests/timeskip-real.test.mjs alone gave the same single failure 3 times out of 3 (6 passed, 1 failed each run). The full host suite here: 1,225 tests, 1,118 pass, 2 fail, 105 skipped; this is one of the two.

Consequence for a person on Linux or a Mac: pressing Stop leaves the revision program running - it keeps using the CPU, and it can still write where the copies folder was supposed to be left alone (the test's own next assertions, plan.md unchanged and half-done.md never reaching the person's folder, are never reached because the grandchild assertion stops the test first).

Expected: Stop ends the job and everything the job started, on every platform - what the function's name and the test's message both say.

Suggested shape: this app already does it right one file over - apps/host/server/native-control.mjs:203 terminates with process.kill(-proc.pid, signal) on non-Windows (falling back to proc.kill) and spawns with detached: process.platform !== 'win32' at lines 332 and 359, so the child is its own process-group leader and the negative pid reaches the group. Doing the same for the two timeskip spawns (detached on non-Windows, then signal -pid) would make killTree live up to its name.

Reproduction status: measured on this box for Linux (3 of 3 deterministic, with the file run in isolation to rule out suite interference). Windows and macOS NOT tested here - the Windows branch reads as correct by inspection, and the macOS branch shares the else path with Linux, so the same gap is expected there. Nothing in the fork's own code (apps/host carries only the Memory tab files) touches this path; it is upstream's.

Originally created by @TheHubUser4860938 on GitHub (Oct 28, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4529 Problem: `apps/host/server/timeskip.mjs:148` is named `killTree`, and its two branches are not equivalent. ```js function killTree(child) { try { if (process.platform === 'win32' && child.pid) spawnSync('taskkill', ['/PID', String(child.pid), '/T', '/F'], { windowsHide: true, stdio: 'ignore' }); else child.kill('SIGTERM'); } catch { /* already gone */ } } ``` On Windows `/T` takes the whole tree with it. On Linux and macOS only the direct child - the `python … cli` the job spawns at line 305 / line 454, and neither spawn is `detached` - is signalled, so anything that program started survives, re-parented to init. The Time Skip job runs the person's revision command as exactly that kind of grandchild. Your own test expects the tree to go on every platform: `apps/host/tests/timeskip-real.test.mjs:119` polls `process.kill(pid, 0)` for 6 s after `stop(id)` and asserts `the revision command (a grandchild of the job) was ended too`. Measured on this box (Linux, Node 26.12.1, source checkout at commit e29f8c29, `npm test` in apps/host): that assertion fails, and it is **deterministic, not timing** - `node --test tests/timeskip-real.test.mjs` alone gave the same single failure 3 times out of 3 (6 passed, 1 failed each run). The full host suite here: 1,225 tests, 1,118 pass, 2 fail, 105 skipped; this is one of the two. Consequence for a person on Linux or a Mac: pressing Stop leaves the revision program running - it keeps using the CPU, and it can still write where the copies folder was supposed to be left alone (the test's own next assertions, `plan.md` unchanged and `half-done.md` never reaching the person's folder, are never reached because the grandchild assertion stops the test first). Expected: Stop ends the job and everything the job started, on every platform - what the function's name and the test's message both say. Suggested shape: this app already does it right one file over - `apps/host/server/native-control.mjs:203` terminates with `process.kill(-proc.pid, signal)` on non-Windows (falling back to `proc.kill`) and spawns with `detached: process.platform !== 'win32'` at lines 332 and 359, so the child is its own process-group leader and the negative pid reaches the group. Doing the same for the two timeskip spawns (detached on non-Windows, then signal -pid) would make `killTree` live up to its name. Reproduction status: measured on this box for Linux (3 of 3 deterministic, with the file run in isolation to rule out suite interference). Windows and macOS NOT tested here - the Windows branch reads as correct by inspection, and the macOS branch shares the `else` path with Linux, so the same gap is expected there. Nothing in the fork's own code (apps/host carries only the Memory tab files) touches this path; it is upstream's.
Author
Owner

@Nyarlathoteppppp commented on GitHub (Oct 29, 2026):

I have a fix with a regression test that fails before and passes after; opening a PR shortly.

<!-- gh-comment-id:6486800135 --> @Nyarlathoteppppp commented on GitHub (Oct 29, 2026): I have a fix with a regression test that fails before and passes after; opening a PR shortly.
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Hello TheHubUser4860938,

Thank you. In Strata 0.2.11 a Time Skip job leads its own process group on Linux and macOS, and Stop (and the timeout of an agent command) sends SIGTERM, then SIGKILL, to the group, as taskkill /T does on Windows. In a real-app test a command with child processes was fully gone 4.5 seconds after Stop. The agent harness's own Stop still signals the agent process only; we left that as it is. If a child process outlives Stop on 0.2.11, please tell us which command started it.

The Strata project

<!-- gh-comment-id:6658460294 --> @Niko1221 commented on GitHub (Nov 5, 2026): Hello TheHubUser4860938, Thank you. In Strata 0.2.11 a Time Skip job leads its own process group on Linux and macOS, and Stop (and the timeout of an agent command) sends SIGTERM, then SIGKILL, to the group, as taskkill /T does on Windows. In a real-app test a command with child processes was fully gone 4.5 seconds after Stop. The agent harness's own Stop still signals the agent process only; we left that as it is. If a child process outlives Stop on 0.2.11, please tell us which command started it. The Strata project
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2042
No description provided.