You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 04c981b
Browse filesBrowse the repository at this point in the historyBrowse files
test(api): poll observable conditions instead of sleeping in the opencode-go spec
The base's api-provider-hygiene ruleset restricts setTimeout in provider specs
(packages/config-eslint/api-provider-hygiene.js, blob 46fc303 on main). That rule reaches this file only on the merge tree: the branch's own copy of the rules file (blob 99dac3a) does not carry it, so lint at the branch head prints 0 problems while CI's run on pull/1652/merge printed 13 no-restricted-globals errors. This commit removes all 13 sleep sites so the merge-tree lint clears; it exists because of the rule, not because a reviewer asked for it.
Each wait now names the condition the sleep stood in for:
- the two model-catalog gates park the exact promise the provider awaits and poll
getModels being called once before aborting, then await that same promise so the
provider's continuation drains first;
- the three streaming mocks publish firstChunkDelivered after their first yield, poll
the captured request signal for aborted, and then throw the path's abort error
unconditionally, so abort identity assertions still run against a real abort;
- the three test-side waits poll firstChunkDelivered before calling controller.abort();
- the two SDK-timeout mocks poll the forwarded request signal for aborted before
throwing AnthropicTimeoutError / APIConnectionTimeoutError, which also proves the
provider forwarded a signal at all;
- the deadline helper gates resolveModel instead of delaying it, so the bounded
resolution test asserts the lookup is still pending at the deadline instead of
assuming it after a sleep.
Verification (node 22.23.4, interpreter pinned by .nvmrc apart from PATH's v25.9.0):
- src tsc --noEmit -p tsconfig.json: exit 0, 0 error lines.
- vitest run api/providers/__tests__/opencode-go.spec.ts from src: 187 passed (187),
exit 0, on three consecutive runs.
- Two-sided catch control: neutering the Anthropic completion catch fails
'preserves abort identity when the caller aborts mid-request (Anthropic path)' and
'preserves abort identity for a name-based AbortError rejection (Anthropic path)'
(2 failed | 5 passed | 180 skipped); restoring the provider to blob
ba80291 and re-running prints 7 passed.
- Converted waits are not hang detectors: breaking each polled condition prints a
failure at that test. Park count 1 -> 2 fails with 'expected vi.fn() to be called 2
times, but got 1 times' on both park tests; never releasing the parked lookup times
the test out; never setting firstChunkDelivered fails 'aborts the in-flight request
when the external signal fires mid-stream'; removing the controller.abort() call
fails the same test through the stream's own abort poll; raising the Anthropic
timeout to 30_000 makes 'surfaces request timeouts as an AbortError (Anthropic
path)' fail with the wait failure surfacing as the completion error.
- Merge-tree reproduction (scratch worktree, merge commit 6a843edd99476ac247a7e6a277
d13cd9491cdf93 = e487cd7 + 9ae937b
a2de3c3b727b72ac08): its lint prints exactly CI's 13 errors; with these conversions
replayed onto the merged copy the same lint exits 0 and the spec against the merged
provider prints 188 passed (188).
- src/eslint-suppressions.json was left byte-identical (prune run restored).
Gate accounting: packageForPath() returns null for a __tests__/ spec path, so the
mutation-diff leg charges 0 executable changed lines for this file — cancelled for
this commit's content, not green.
0 commit comments