Repository navigation
test(server): settle the abandoned installation-token request so stores.test.ts passes in any order (__tests__/server/stores.test.ts) - #633
Conversation
…es.test.ts so the file passes in any order (__tests__/server/stores.test.ts) @octokit/auth-app 8 deduplicates concurrent token requests per installation in a module-level map shared by every createAppAuth in the process. The 'main() gives up waiting after the grace period' case answered the access_tokens request with a promise that never resolves, so any later test in the file that mints a token for installation 7 hung until its timeout without issuing a request. In source order only token-free cases follow it, which is why the default run stayed green; 'npm run test:shuffle' fails under seeds 777, 31 and 20261030 at main@ed3bb42. The handler now holds on a promise the test settles with a 500 in its finally, the parked delivery's error line is awaited before the stdout spy is restored, and listening.close(0) is called as the sibling cases do. The contributing guide's 'Test order' section names this fourth leak. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Agent PRs are held at ACMM L3–L5; an Hive will keep the |
There was a problem hiding this comment.
Read the diff against the tree at merge-base and the PR head; this looks correct to me.
What I verified:
- The mechanism is real:
@octokit/auth-app8 dedupes concurrent installation-token requests in a module-levelpendingPromisesmap (dist-src/get-installation-authentication.js:25), shared across everycreateAppAuthin the process. The old handler's() => new Promise(() => {})therefore parks every later mint for installation 7 in this file — the body's seed-777 reproduction matches what I traced independently on this suite. await listening.close(0)in the newfinallyis safe after the SIGINT exit path:close()memoizes viaclosing ??=(src/server/node.ts:157-160), so the second call just returns the settled promise. This matches the siblingmain()cases (e.g. the graceful-shutdown case'sfinallyat tests/server/stores.test.ts:211).- The 500 genuinely ends the delivery with no further requests: the node server path builds octokit without a retry plugin (src/utils/octokit.ts; the only
retryin src/ is the queue-message retry in src/server/worker.ts:165). - Awaiting the parked delivery's
errorlog line beforewrite.mockRestore()(tests/server/stores.test.ts:247-248) is the right order — the late log otherwise lands in whichever spy the next test installs. - docs/contributing.md "Test order" count 3→4 is consistent with the added bullet.
The diff does exactly what the body claims, scope is one test case plus the doc paragraph, and the hold gate means a maintainer still merges. No findings.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
|
/kind cleanup 🐝 Hive Agent: — hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
…nightly, and guard the Worker's entry points (#635) Three gaps the last month of quality findings kept hitting by hand: - test.yml gains a `shuffle` job running `npm run test:shuffle` (with the Redis service, so the store tests are in the order too). #633 found an order-poisoning pair only because someone ran the shuffle locally; the suite passes in source order by luck and nothing in CI knew. - test.yml gains a `mutation` job on the daily schedule and on workflow_dispatch, running `npm run test:mutation:nightly` — stryker.nightly.config.mjs, the default merge-decision set of stryker.config.mjs with no incremental file and a `break` score of 95 (main reaches 96 with six equivalent survivors). The job writes a per-file tally to the step summary and uploads reports/mutation/. The schedule trigger existed and gated nothing extra. This is the single-shard form of #594's proposal; the whole-tree five-shard matrix (5+ hours of runner time nightly) is declined for now. - __tests__/worker/entryPoints.test.ts: src/server/worker.ts is excluded from both coverage runs because it only executes inside workerd, so scheduled(), queue() and deferViaQueue shipped with no test and no number moved (#629). The guard parses the file's default-export handlers, Hono routes and top-level functions, requires each to be listed with the evidence in __tests__/worker that drives it, and requires that evidence to be present — a new entry point or a deleted driver fails the unit run. The exclusion comment in vitest.config.mjs points at it. docs/contributing.md records the two jobs and the new script. Closes #594 Signed-off-by: Bob Killen <bkillen@linuxfoundation.org> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Test Improvement
One existing case in
__tests__/server/stores.test.ts—main() gives up waiting after the grace period— plus a paragraph indocs/contributing.md("Test order"). Nosrc/, config, chart or workflow change.POST /app/installations/7/access_tokenshandler no longer returns a promise that never resolves; it holds on a promise the test settles with a500in itsfinallyerrorlog line is awaited beforeprocess.stdout.writeis un-spied, so nothing leaks into the next test's listenerslistening.close(0)is called infinally, as the siblingmain()cases already doWhy.
@octokit/auth-app8.3.1 deduplicates concurrent token requests per installation in a module-level map (dist-src/get-installation-authentication.js:25,pendingPromises), shared by everycreateAppAuthin the process — not one per App or receiver. A token request the test never answers therefore parks every laterinstallationToken(7)in the same file: the next test that mints a token hangs until its 5 s timeout without issuing a request (traced:SEEN done→TOKEN start→ nothing, nofetch, no WebCrypto call). In source order only token-free cases followgives up, so the default run is green by luck.Evidence at main@ed3bb42:
npx vitest run --sequence.shuffle --sequence.seed=<s> --exclude '__tests__/bundle/**'fails under seeds777(1 test),31and20261030(3 tests each), all in__tests__/server/stores.test.ts; pairwise reordering isolatesgives up→locks an event about no issue or pull request under its own delivery idas the only poisoning pair.npm run test:shuffleis not a CI step, so nothing caught it.grepshows no other test file answers anaccess_tokensrequest with a never-settling promise.Files / cluster claimed —
__tests__/server/stores.test.ts(one case) anddocs/contributing.md(Test order). Held #631 also editsstores.test.tsbut adds cases and leavesgives upuntouched;git merge-tree --write-treeof this head against #626, #630, #631 and #632 is clean. #631's newmain() with nothing in flightcase mints no token, so it is not affected either way.Testing
npx vitest run __tests__/server/stores.test.tsdefault order and seeds 777/31/20261030: 10/10npx eslint __tests__/server/stores.test.tsandnpx tsc -p tsconfig.test.json— clean() => new Promise(() => {})reproduces the timeout under seed 777 on the single fileRelated Issue
None — a test-order regression in an existing file with a one-case fix; the standing "test order" class and its CI gate (a shuffled
test.ymljob, workflow file, needs a human) were already recorded earlier.Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88