Fix a race in the cancel_command test
CI / Lint (eslint) (pull_request) Successful in 20s
CI / Test (jest) (pull_request) Successful in 19s
CI / Security (npm audit) (pull_request) Successful in 12s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 3m9s
CI / Integration (api) (pull_request) Successful in 4m1s
CI / UI screenshots (before/after) (pull_request) Successful in 11s
CI / UI (playwright) (pull_request) Successful in 2m38s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI / Lint (eslint) (pull_request) Successful in 20s
CI / Test (jest) (pull_request) Successful in 19s
CI / Security (npm audit) (pull_request) Successful in 12s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 3m9s
CI / Integration (api) (pull_request) Successful in 4m1s
CI / UI screenshots (before/after) (pull_request) Successful in 11s
CI / UI (playwright) (pull_request) Successful in 2m38s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
The shell creates a redirect target before writing to it, so the test could read an empty pid file, take pid 0, and decide the child was not running. This failed the push run of #80's merge, so that commit was not deployed. The command now writes the pid to a temporary file and renames it into place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
33a3f7c0b9
commit
0412eeeb38
1 file changed
+3
-1
@@ -126,7 +126,9 @@ describe('cancel_command (#8)', () => {
|
||||
test('cancelling stops the command and everything it started', async () => {
|
||||
const w = makeWorker();
|
||||
const pidFile = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'pulse-cancel-')), 'pid');
|
||||
const pending = w.executeCommand({ command: `sleep 30 & echo $! > ${pidFile}; wait`, execution_id: 'ex-c', command_id: 'cmd-c' });
|
||||
// Write then rename: the shell creates a redirect target before writing to it,
|
||||
// so reading ${pidFile} directly could see an empty file (pid 0).
|
||||
const pending = w.executeCommand({ command: `sleep 30 & echo $! > ${pidFile}.tmp && mv ${pidFile}.tmp ${pidFile}; wait`, execution_id: 'ex-c', command_id: 'cmd-c' });
|
||||
for (let i = 0; i < 50 && !fs.existsSync(pidFile); i++) await new Promise(r => setTimeout(r, 50));
|
||||
const childPid = Number(fs.readFileSync(pidFile, 'utf8'));
|
||||
expect(alive(childPid)).toBe(true);
|
||||
|
||||
Reference in new issue
Block a user