Skip to content

fix(server): stop the launcher dying to a signal while it starts - #588

Merged
ArgaFairuz merged 1 commit into
mainfrom
fix/ci-unit-tests
Nov 18, 2026
Merged

ArgaFairuz merged 1 commit into
mainfrom
fix/ci-unit-tests

Conversation

@ArgaFairuz

Copy link
Copy Markdown
Collaborator

Summary

Makes Unit Tests pass on CI again. The launcher test has failed on every push since #585, and a diff test failed now and then before that. 0.4.50 was retracted because of this and will be re-cut once this is merged.

Why

  • Launcher test (failed every CI run, passed locally). stopOnSignals ran ps three times (parentForwardsSignals) before it installed any signal handler. Until a handler exists, a signal takes its default action, so a SIGHUP or SIGINT in that window killed the supervisor outright. The server kept running with nothing to restart it. On a slower runner the window outlasted the server's start-up, which is exactly when the test sends SIGHUP. This is a real bug, not only a test bug: a Ctrl+C or a closed terminal during launch could leave an orphaned server.
  • Diff invariant test (intermittent). It diffed a fully reversed 20,000-line file, which is Myers' worst case. That took 3 to 5 s against bun's 5 s default timeout, so whether it passed depended on the runner's load. It first appeared with fix(diff): stop diffs from freezing the server or the browser tab #578.
  • Git identity test (local only). Run from a shell that Clopen started, GIT_CONFIG_COUNT/KEY_n/VALUE_n (which outrank every config file) supplied the developer's own identity.

Changes

  • shared/utils/process-supervisor.ts: install every handler first and run parentForwardsSignals() last. A signal that arrives meanwhile is queued, and its handler sees the right value.
  • frontend/utils/line-diff.test.ts: the reversed case now uses 4,000 lines (~150 ms instead of 3 to 5 s). The invariant does not depend on size, and in the app the diff runs in a worker.
  • backend/git/identity/scope-config.test.ts: strip GIT_CONFIG_COUNT/KEY_n/VALUE_n before calling git.

Test plan

  • bun run check, bun run lint
  • bun run test: 1986 pass, 0 fail
  • Reproduced the CI failure locally by putting a ps that sleeps 300 ms on PATH. Before the change the launcher test failed at the same line as on CI (process-supervisor.test.ts:233); after it, 3/3 runs pass.
  • CI green on this PR

Notes

CI installs bun-version: latest (1.4.4 today) while local is 1.3.14. That was not the cause here, since the test passes on 1.4.4 in Docker, but it is a source of drift worth pinning separately.

Unit tests failed on CI for every push since #585, and a diff test failed
now and then before that.

The launcher test failed every time on CI and never locally. stopOnSignals
asked ps three times whether its parent was a bun runner before it
installed any signal handler. Until a handler exists a signal takes its
default action, so SIGHUP or SIGINT in that window killed the supervisor
outright and left the server running with nothing to restart it. A slower
runner made the window wider than the server's start-up, which is when
the test sends SIGHUP. The handlers are now installed first and ps runs
last; a signal that arrives meanwhile waits for its handler. With ps
slowed by 300 ms the test failed every run before the change and passes
after.

The diff invariant test diffed a fully reversed 20,000-line file, Myers'
worst case. That took 3 to 5 s against bun's 5 s timeout, so it passed or
failed with the runner's load. The case keeps its shape at 4,000 lines;
the invariant does not depend on size, and the diff runs in a worker in
the app.

The git identity test read the developer's own name when run from a shell
Clopen started: GIT_CONFIG_COUNT/KEY_n/VALUE_n outrank every config file.
The test now drops them.
@ArgaFairuz
ArgaFairuz merged commit 2d5ad21 into main Nov 18, 2026
2 checks passed
@ArgaFairuz
ArgaFairuz deleted the fix/ci-unit-tests branch November 18, 2026 12:05
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