Skip to content

Commit b1b35a3

Browse files
test(rest): fail the late-cancel control loudly when its wait for the results write runs out (#28067)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DFm2bnNC5WSDWCqwoXTpNTR)_ domain:server#3 · os-elon-musk · session_016WV4cyGcBtnptfcfKE14ZS Fixes #27839 ## What changes In `packages/rest/src/import-job-integration.test.ts`, the control "a cancel that lands after the last row still wins over an all-failed outcome" now records how many rows the `results` read returned during its 400 × 5 ms wait, and asserts it reached 3 before it checks the job row. Test-only; no product change. ## Why The worker's final patch is the only write of `results`. If the wait ran out, the cancel route's own `cancelled` write and the progress flush could satisfy the status and count checks without the final patch ever landing. The new assertion makes an exhausted wait fail on its own cause (contract review of #27795, record 6512470441, should-fix 1). ## Verification - `npx vitest run src/import-job-integration.test.ts` in `packages/rest`: 21/21 pass. - Ablation (local, restored): with the wait loop cut to 0 iterations, the new line fails with `expected +0 to be 3`. Under the same ablation the pre-change test also fails, but on the later `toMatchObject` counts, which does not name the wait. - `packages/rest` full suite: 357 files, 7073 passed, 350 skipped. - `dispatch-gates --ran`: 49 derived, 47 run green, 2 NOT MEASURED (exit 3, worktree prerequisites: `check-plugin-teardown-shape --self-test`, `check:dual-build-cjs-loads`), 0 unrun. - `pnpm lint`: exit 0. Skills-docs: none. `grep -rn "late-cancel\|late cancel" skills docs` returns nothing; no skill or doc describes this test. Clause-②: no Metadata-protocol: none No changeset: a test file publishes nothing from any released package (`skip-changeset`). ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (not touched) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. (publishes nothing) - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. (not touched) - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016WV4cyGcBtnptfcfKE14ZS Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2ecf6a7 commit b1b35a3

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎packages/rest/src/import-job-integration.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,11 +618,16 @@ describe('async import job — a job whose every row failed ends failed', () =>
618618
await waitForTerminal(slowCtx.progress, jobId);
619619
// The cancel route writes `cancelled` first; wait until the worker's own
620620
// final patch has landed (it is the only write of `results`), then read the row.
621+
let reported = 0;
621622
for (let i = 0; i < 400; i++) {
622623
const r = await callJob(slowCtx.results, jobId);
623-
if ((r._json?.results ?? []).length === 3) break;
624+
reported = (r._json?.results ?? []).length;
625+
if (reported === 3) break;
624626
await new Promise((rr) => setTimeout(rr, 5));
625627
}
628+
// An exhausted wait must fail here: without the worker's final patch, the
629+
// cancel route's write and the progress flush alone could pass the checks below.
630+
expect(reported).toBe(3);
626631
const after = await callJob(slowCtx.progress, jobId);
627632
expect(after._json.status).toBe('cancelled');
628633
expect(after._json).toMatchObject({ processed: 3, created: 0, updated: 0, skipped: 0, errors: 3 });

0 commit comments

Comments
 (0)