Skip to content

test(plugin): wait for the v2 lazy-refresh tier instead of sleeping past it - #12984

Merged
diegosouzapw merged 1 commit into
release/v3.8.51from
test/opencode-v2-lazy-refresh-race
Sep 12, 2026
Merged

diegosouzapw merged 1 commit into
release/v3.8.51from
test/opencode-v2-lazy-refresh-race

Conversation

@diegosouzapw

Copy link
Copy Markdown
Owner

Fixes a pre-existing race in the opencode plugin v2 suite. Surfaced by #12965 —
that PR is a dependency bump and does not cause this; it is simply the first PR
in a while to touch @omniroute/opencode-plugin-v2/, which is what makes the job
run at all.

The race

lazy refresh: [m1] then [m1,m2] reloads once; identical runs never reload waits
for the plugin's asynchronous optional tier with a fixed await sleep(5). When
the tier lands after that sleep, its reload is still pending and the next
assertion counts it:

✖ lazy refresh: [m1] then [m1,m2] reloads once; identical runs never reload
  AssertionError: an identical run never reloads
  2 !== 1

The file fails on every isolated run against the current release/v3.8.51
tip, with no changes applied. It only passed when the whole suite ran together
and unrelated work happened to give the tier enough slack — which is why the
green local npm test and the red CI job disagreed.

The fix

Both sleeps become await settle(() => reloads): poll until the observed value
holds steady for three consecutive turns, with a 5s ceiling. The wait now tracks
the work instead of the clock. The assertions themselves are untouched —
this changes how the test waits, not what it verifies.

Why nobody saw it

.github/workflows/opencode-plugin-ci.yml filters on

paths:
  - "@omniroute/opencode-plugin/**"
  - "@omniroute/opencode-plugin-v2/**"

so Test v2 only runs when those directories change. The nightly release-green
sweep never triggers it, and the failure stayed off the base-red radar.

Validation

Check Before After
tests/index.test.ts isolated, 6 runs 0/6 green 6/6 green
full v2 suite (npm test) 218/218 218/218
npm run build (tsup) pass pass
prettier --check — clean

Diff is one file: @omniroute/opencode-plugin-v2/tests/index.test.ts.

⚠️ base-red inherited: #12732 — release/v3.8.51 is not green; any failing
check outside Test v2 on this PR comes from the tip, not from this branch.

…ast it

`lazy refresh: [m1] then [m1,m2] reloads once; identical runs never reload`
waited for the plugin's asynchronous optional tier with a fixed `await sleep(5)`.
That is a race, not a wait: when the tier landed after the sleep, its reload was
still pending, so the next assertion counted it and read

    AssertionError: an identical run never reloads
    2 !== 1

The test file fails on every isolated run on the current release tip; it only
passed when the whole suite ran together and unrelated work happened to give the
tier enough slack.

Replaces both sleeps with a `settle()` helper that polls until the observed value
holds steady for three consecutive turns (5s ceiling), so the wait tracks the
work rather than the clock. The assertions are unchanged — this fixes how the
test waits, not what it checks.

The failure was invisible to the base-green sweep because
`.github/workflows/opencode-plugin-ci.yml` filters on
`paths: @omniroute/opencode-plugin*/**`, so the job only runs when the plugin
directories change and the nightly sweep never triggers it.

Isolated file: 6/6 runs green (was 0/6). Full v2 suite: 218/218. Build passes.
@diegosouzapw
diegosouzapw merged commit 95ebed7 into release/v3.8.51 Sep 12, 2026
18 of 26 checks passed
Githab-capibara added a commit to Githab-capibara/OmniRoute that referenced this pull request Sep 17, 2026
…ast it (diegosouzapw#12984)

Merged as part of the owner batch of 2026-09-11.

This PR had a live worktree in another session, so it sat outside the main 39. Merged on your explicit call, validated first rather than taken on trust: boarded with the other 10 worktree-held PRs into a consolidated worktree off `release/v3.8.51`.

- ESLint over every changed file: no errors
- `typecheck:core` clean; `check:dashboard-typecheck` OK; `check:changelog-integrity` OK
- complexity 2821 / baseline 3218 and cognitive-complexity 1272 / baseline 1437
- 203 of 208 assertions green. The 5 remaining (`guide-settings-route` ×4, `hard-session-lease-bypass-inventory` ×1) reproduce on the pure tip with nothing from this batch applied.
- `imageGeneration.ts` rebaselined 3259 → 3293 for diegosouzapw#12945's image-only-model guard, landed separately in diegosouzapw#13392 so nothing was pushed onto a live branch.

⚠️ base-red inherited: diegosouzapw#12732 — provider count 356 vs 358 and `open-sse/utils/stream.ts` 3115 > frozen 3098, both reproducing on the pure tip.
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…ast it (diegosouzapw#12984)

Merged as part of the owner batch of 2026-09-11.

This PR had a live worktree in another session, so it sat outside the main 39. Merged on your explicit call, validated first rather than taken on trust: boarded with the other 10 worktree-held PRs into a consolidated worktree off `release/v3.8.51`.

- ESLint over every changed file: no errors
- `typecheck:core` clean; `check:dashboard-typecheck` OK; `check:changelog-integrity` OK
- complexity 2821 / baseline 3218 and cognitive-complexity 1272 / baseline 1437
- 203 of 208 assertions green. The 5 remaining (`guide-settings-route` ×4, `hard-session-lease-bypass-inventory` ×1) reproduce on the pure tip with nothing from this batch applied.
- `imageGeneration.ts` rebaselined 3259 → 3293 for diegosouzapw#12945's image-only-model guard, landed separately in diegosouzapw#13392 so nothing was pushed onto a live branch.

⚠️ base-red inherited: diegosouzapw#12732 — provider count 356 vs 358 and `open-sse/utils/stream.ts` 3115 > frozen 3098, both reproducing on the pure tip.
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