Public: anyone can read this; the crew can change it.

"RepoSource: one repository, two places to read it from > a mirror reports its stages in order and ends holding the repo" passes every time on a loaded check machine #5399

opened this

Merged 40d 2h ago, live in production

The test is fixed and no product code changed. bun test --rerun-each 30 test/view-source.test.ts -t "a mirror reports its stages" passes 30 of 30, and the whole file passes (23 tests). I didn't get a type check: tsc has no bun types here and I didn't run bun install.

Notes

opened this

The test is fixed and no product code changed. bun test --rerun-each 30 test/view-source.test.ts -t "a mirror reports its stages" passes 30 of 30, and the whole file passes (23 tests). I didn't get a type check: tsc has no bun types here and I didn't run bun install. I've pushed the branch but haven't seen the forge's check result yet.

Cause: this was a race in the test. subscribe() in src/origins/jobs.ts replays only the stage the job is on when you subscribe, which is by design. The test subscribed after the POST returned and its body was read. On a loaded machine the mirror could finish in that gap. The subscriber then saw only done, so seen[0] was not creating and issues was missing.

Change:

  • The fake forge in test/fake-origin.ts gets an optional holdLabels promise that holds the label-list GET until it resolves.
  • The test sets it before the POST and releases it once it is subscribed. The job then can't get past the label import before the test is listening. It waits on that promise, with no sleep.
  • seen starts with the creating stage from the 202 response, since the subscription can no longer observe it.
  • Every assertion is unchanged: stage order, first is creating, last is done, issues seen, repo and finishedAt set. No timeouts or retries were added.

Left out: I didn't add stage history to jobs. The product behaves as designed, and the replay-latest rule is what the UI relies on.

Closes #5394

commented

The test is fixed and no product code changed. bun test --rerun-each 30 test/view-source.test.ts -t "a mirror reports its stages" passes 30 of 30, and the whole file passes (23 tests). I didn't get a type check: tsc has no bun types here and I didn't run bun install. I've pushed the branch but haven't seen the forge's check result yet.

Cause: this was a race in the test. subscribe() in src/origins/jobs.ts replays only the stage the job is on when you subscribe, which is by design. The test subscribed after the POST returned and its body was read. On a loaded machine the mirror could finish in that gap. The subscriber then saw only done, so seen[0] was not creating and issues was missing.

Change:

  • The fake forge in test/fake-origin.ts gets an optional holdLabels promise that holds the label-list GET until it resolves.
  • The test sets it before the POST and releases it once it is subscribed. The job then can't get past the label import before the test is listening. It waits on that promise, with no sleep.
  • seen starts with the creating stage from the 202 response, since the subscription can no longer observe it.
  • Every assertion is unchanged: stage order, first is creating, last is done, issues seen, repo and finishedAt set. No timeouts or retries were added.

Left out: I didn't add stage history to jobs. The product behaves as designed, and the replay-latest rule is what the UI relies on.

commented

The mirror-stages test no longer fails when the machine is loaded. No product code changed. The type errors that failed the check are fixed, and I've pushed the fix. tsc --noEmit is clean locally. The whole of test/view-source.test.ts passes 10 times over (230 runs, 0 fail). I haven't seen the forge's new check result yet.

Cause: a race in the test. subscribe() in src/origins/jobs.ts replays only the stage the job is on when you subscribe, by design. The test subscribed after the POST returned. On a loaded machine the mirror could finish in that gap, so the subscriber saw only done. Then seen[0] was not creating and issues was missing.

Change:

  • The fake forge in test/fake-origin.ts gets an optional holdLabels promise that holds the label-list GET until it resolves.
  • The test sets it before the POST and releases it once subscribed. That pins the job before its label import, and the test waits on the promise, not a sleep.
  • seen starts from the creating stage reported in the 202 response, since the subscription can no longer observe it.
  • All assertions are unchanged, and no timeouts or retries were added.

Check failure: holdLabels now has the type Promise<void> | undefined, which exactOptionalPropertyTypes requires. The job's stage is now typed MirrorStage.

Left out: I didn't add stage history to jobs. The replay-latest behaviour is what the UI relies on.

To try: bun test --rerun-each 30 test/view-source.test.ts -t "a mirror reports its stages".

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs