You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "liugddx (via GitHub)" <gi...@apache.org> on 2026/10/23 09:34:44 UTC

[I] test(runtime-host): ShellRun process crash recovery is intermittently flaky (non-atomic ready.json) [maka]

liugddx opened a new issue, #6266:
URL: https://github.com/apache/maka/issues/6266

   ## What happened
   
   The test `ShellRun process crash recovery from <phase> does not redispatch` in `packages/runtime-host/src/__tests__/goal-root-authority.test.ts` fails intermittently. It also fails on `origin/main`: reproduced locally at `59f61cf7d` (3 of 10 runs). The recent CI runs on `main` happened to pass.
   
   The fixture is a child process that writes `ready.json` with a plain `writeFile` (around line 3301 at `59f61cf7d`). The parent polls for that file and reads it:
   
   ```ts
   marker = JSON.parse(await readFile(join(base, 'ready.json'), 'utf8'));
   ...
   if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false;
   throw error;
   ```
   
   The poll tolerates only `ENOENT`. When the parent reads between the child's open and its final write, it sees a truncated file and `JSON.parse` throws. That error is rethrown and fails the test.
   
   Two failure signatures observed:
   
   | Where | Phase | Error |
   |---|---|---|
   | CI, PR #6256, run 39915078540, job 120315826428 | `terminal` | `SyntaxError: Unexpected end of JSON input` |
   | Local, Node 24.21.0 | `running` | `ENOENT: no such file or directory, open '.../root/starts'` |
   
   The second signature is a different race in the same fixture: the parent asserts on a `starts` file the child has not written yet.
   
   ## How to reproduce
   
   At `59f61cf7d`, Node 24.21.0, from `packages/runtime-host`:
   
   ```sh
   npm run build
   for i in $(seq 1 10); do
     node --test --test-concurrency=1 --test-name-pattern="ShellRun process crash recovery" dist/__tests__/goal-root-authority.test.js || echo FAIL $i
   done
   ```
   
   Observed: 3 of 10 runs failed. The test is not in an assistant suite, and the `test:dist` run includes it.
   
   ## Suggested fix (not implemented)
   
   - Make the child write `ready.json` atomically: write to a temporary file and `rename` it into place.
   - Treat `SyntaxError` from `JSON.parse` as "not ready yet" in the poll, the same as `ENOENT`.
   - Wait for `starts` before asserting on it, or make the child create it before signalling readiness.
   
   ## Environment
   
   - Maka: `59f61cf7d` (`origin/main`)
   - OS: macOS, Darwin 25.5.0 (local); Ubuntu (CI)
   - Surface: Runtime Host test suite
   - Node.js: 24.21.0 locally; CI uses Node 24
   
   ## Related
   
   - PR #6256 failed on this test; the change in #6256 does not touch shell runs or this file.
   
   <details>
   <summary><b>中文版(点击展开)</b></summary>
   
   **标题:** test(runtime-host):ShellRun 崩溃恢复测试间歇性失败(子进程写 ready.json 非原子)
   
   ## 发生了什么
   
   `packages/runtime-host/src/__tests__/goal-root-authority.test.ts` 中的 `ShellRun process crash recovery from <phase> does not redispatch` 间歇性失败。它在 `origin/main` 上也会失败:在本地 `59f61cf7d` 复现(10 次中 3 次失败)。`main` 最近几次 CI 恰好通过。
   
   夹具是一个子进程,它用普通的 `writeFile` 写 `ready.json`(`59f61cf7d` 上约第 3301 行)。父进程轮询并读取该文件:
   
   ```ts
   marker = JSON.parse(await readFile(join(base, 'ready.json'), 'utf8'));
   ...
   if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false;
   throw error;
   ```
   
   轮询只容忍 `ENOENT`。当父进程在子进程写入的中途读取时,会读到截断的文件,`JSON.parse` 抛错,测试随之失败。
   
   观察到两种失败特征:
   
   | 位置 | 阶段 | 错误 |
   |---|---|---|
   | CI,PR #6256,run 39915078540,job 120315826428 | `terminal` | `SyntaxError: Unexpected end of JSON input` |
   | 本地,Node 24.21.0 | `running` | `ENOENT: ... root/starts` |
   
   第二种是同一夹具中的另一个竞态:父进程在子进程写入 `starts` 文件之前就对它做断言。
   
   ## 复现步骤
   
   在 `59f61cf7d`、Node 24.21.0、`packages/runtime-host` 目录下:
   
   ```sh
   npm run build
   for i in $(seq 1 10); do
     node --test --test-concurrency=1 --test-name-pattern="ShellRun process crash recovery" dist/__tests__/goal-root-authority.test.js || echo FAIL $i
   done
   ```
   
   观察结果:10 次中有 3 次失败。
   
   ## 建议修复(未实现)
   
   - 子进程原子地写入 `ready.json`:先写临时文件,再 `rename` 到位。
   - 轮询中把 `JSON.parse` 的 `SyntaxError` 视为"尚未就绪",与 `ENOENT` 同等处理。
   - 在断言 `starts` 之前等待它出现,或让子进程在发出就绪信号前先创建它。
   
   ## 环境
   
   - Maka:`59f61cf7d`(`origin/main`)
   - 系统:macOS(本地),Ubuntu(CI)
   - 范围:Runtime Host 测试套件
   - Node.js:本地 24.21.0;CI 使用 Node 24
   
   ## 相关
   
   - PR #6256 因该测试失败;#6256 的改动不涉及 shell 运行或本文件。
   
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [I] test(runtime-host): ShellRun process crash recovery is intermittently flaky (non-atomic ready.json) [maka]

Posted by "Master-Frank (via GitHub)" <gi...@apache.org>.
Master-Frank commented on issue #6266:
URL: https://github.com/apache/maka/issues/6266#issuecomment-6362770324

   take
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [I] test(runtime-host): ShellRun process crash recovery is intermittently flaky (non-atomic ready.json) [maka]

Posted by "liugddx (via GitHub)" <gi...@apache.org>.
liugddx closed issue #6266: test(runtime-host): ShellRun process crash recovery is intermittently flaky (non-atomic ready.json)
URL: https://github.com/apache/maka/issues/6266


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [I] test(runtime-host): ShellRun process crash recovery is intermittently flaky (non-atomic ready.json) [maka]

Posted by "liugddx (via GitHub)" <gi...@apache.org>.
liugddx commented on issue #6266:
URL: https://github.com/apache/maka/issues/6266#issuecomment-6431281465

   The flaky `ShellRun process crash recovery` tests were removed from main by #6298 (da614305c), so this no longer applies. Closing; #6268 is closed as superseded.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org