Skip to content

ci: fix hanging sessionManager tests and speed up jobs - #43

Merged
nananek merged 2 commits into
masterfrom
perf/ci-speedup
Aug 11, 2026
Merged

ci: fix hanging sessionManager tests and speed up jobs#43
nananek merged 2 commits into
masterfrom
perf/ci-speedup

Conversation

@nananek

@nananek nananek commented Aug 11, 2026

Copy link
Copy Markdown
Owner

概要

CI の遅さ・ハング問題を修正。主因は sessionManager.test.js のプロセス終了待ちハング (CI ジョブがデフォルト 6時間タイムアウトまで占有)。あわせてジョブ構成を高速化した。

原因 (調査: tmp/ci-speedup-plan.md)

  • sessionManager.test.js は単独実行で 300s+ ハング: テストは全パスするが、終了後もイベントループにハンドルが残る (pty master ReadStream / 保持タイマー)
  • npm test (node --test) は子プロセス終了を待つため、この1ファイルのハングで CI ジョブ全体が終わらない
  • 並列実行ではタイミング依存で通る (レース) ため、Node 20 ジョブだけ症状が出た

変更内容

P0-1 ハング修正 (server/ws/sessionManager.js, sessionManager.test.js)

  • destroySessionptyProcess.destroy() を追加 (master ReadStream fd のリーク解消。kill だけでは grandchild が slave fd を保持していると EOF が来ない)
  • onExit の保持タイマー起動に sessions.has(id) ガード (destroy 済みセッションに 30s タイマーを立てない)
  • スケジュール注入フォールバックタイマー (pendingInjectionTimer) をセッションに追跡し、配送時・teardown 時に clearTimeout
  • テスト after フックで destroyAllSessions() を実行し残留ハンドルを解放

P0-2 全3ジョブに timeout-minutes: 30 (ハング再発時の保険)
P1-1 Node 20 削除 (2026-04-30 EOL)・Node 22 固定、README の minimum を 22 に更新
P2 e2e ジョブに Playwright ブラウザキャッシュ (actions/cache)
P3 syntax-check を xargs -P4 で並列化
その他 .gitignore/.claude/ を追加

検証 (ローカル)

  • node --test server/ws/sessionManager.test.js: 300s+ ハング → 14.2s rc=0
  • npm test 全体: 294 tests pass / 16.4s rc=0

sessionManager teardown leaked the pty master read stream: kill() only
signals the child, so a grandchild holding the slave fd kept the stream
open forever and the test runner (and prod) never exited. destroySession
now force-closes the pty via destroy(), and onExit no longer re-arms the
30s exited-session retention timer once the session was already removed.
The 15s resume-inject fallback timer is tracked and cleared on teardown
and on idle-path delivery. sessionManager.test.js alone went from
hanging (300s+) to a stable 14s.

CI: add timeout-minutes: 30 to every job (6h default -> 30min worst
case), drop EOL Node 20 from the unit-tests matrix (README minimum now
22), cache Playwright browsers for e2e, and parallelize syntax-check
with xargs -P4.
@nananek nananek closed this Aug 11, 2026
@nananek nananek reopened this Aug 11, 2026
@nananek
nananek merged commit ac60fb2 into master Aug 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant