Skip to content

Fix GitHub sync service abort race - #1854

Merged
ymichael merged 1 commit into
mainfrom
bb/investigate-flaky-ci-test-thr_h2eb3vwg3g
Aug 18, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/investigate-flaky-ci-test-thr_h2eb3vwg3g

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

What was wrong

The GitHub plugin's sync service could be aborted while syncAll() was still running. After the pass finished, the service installed its retry-delay abort listener without first rechecking the signal. Because AbortSignal does not replay an abort to listeners added later, a failed pass then slept for the full 30-second retry delay. On a loaded packages shard, the test's 150 ms abort landed in that window and hit its 20-second timeout.

What changed

The sync loop now checks for an already-aborted signal before scheduling its next delay. Its delay listener is also removed when the timer completes instead of accumulating across successful sync cycles.

The auth-latch regression now waits for the service's first gh call instead of assuming it starts within 150 ms, deliberately slows that call so abort occurs mid-pass, and verifies that the all-repos failure is caught without advancing the sync cursor. No wire, CLI, or documentation surfaces changed.

How you verified

  • The updated regression times out at exactly 20 seconds before the production fix and passes in about 1 second afterward.
  • pnpm exec turbo run test typecheck --filter=bb-plugin-github --force — 14/14 tests passed and typecheck passed.
  • git diff --check passed.

Fixes #1758

AGENT GENERATED: by GPT-5

@ymichael
ymichael merged commit d3b8b64 into main Aug 18, 2026
12 checks passed
@ymichael
ymichael deleted the bb/investigate-flaky-ci-test-thr_h2eb3vwg3g branch August 18, 2026 23:48
ymichael added a commit that referenced this pull request Aug 19, 2026
## What was wrong

The test suite had three related quality problems: an ACP integration
test used file existence as a proxy for completed output and could race
with a confirmed child-process stdin teardown error ([CI run
32188276525](https://github.com/get-bb/bb/actions/runs/32188276525));
package coverage reports omitted unimported runtime files, hiding
substantial gaps; and high-risk JSON-RPC/GitHub behavior had little
boundary coverage while presentation-only header sizing assertions added
maintenance cost without protecting product behavior. Recent GitHub
sync/auth fixes in #1282, #1758, and #1854 helped identify the missing
regression surfaces. The first PR run also exposed a source-wrapper test
that deep-compared the unrelated, evolving `bb status` payload; Turbo
did not model its hidden `@bb/cli` dependency, so the stale assertion
had previously remained cached green.

## What changed

- Wait for the completed ACP turn rather than file creation, and
suppress only the benign `EPIPE`/`ERR_STREAM_DESTROYED` child-stdin
teardown race.
- Add lifecycle regression tests for ACP connection shutdown and write
completion.
- Add opt-in reproducible V8 coverage for packages using the shared
Vitest configuration. Explicit source globs include files never imported
by tests; normal test and CI runs remain unchanged unless `--coverage`
is passed, and no threshold is imposed.
- Expand provider JSON-RPC coverage from one test to ten across parsing,
malformed messages, schema validation, timeouts, notifications,
structured errors, and exactly-once settlement.
- Add GitHub plugin RPC tests for sync, cache patching, PR/check/review
normalization, pagination, and file patches, plus app tests for routes,
query matching, and suggestions.
- Ensure all GitHub plugin test files are included in typechecking and
remove three presentation-only header sizing tests.
- Keep the source CLI wrapper test focused on clean, parseable JSON and
declare its `@bb/cli#build` Turbo dependency so CLI changes cannot reuse
a stale test result.

There are no server/daemon wire changes, CLI changes, or user-facing
configuration changes, so no protocol-version or guide update is
required.

## How you verified

- [Replacement PR CI run
32311230863](https://github.com/get-bb/bb/actions/runs/32311230863)
passed every required check, including packages, server, integration,
all app shards, and Linux/macOS package smoke.
- `pnpm exec turbo run test --filter=@bb/scripts --force` — 17 files and
92 tests passed; the command explicitly executes `@bb/cli#build` first.
- `pnpm exec turbo run test --filter=@bb/integration-tests --force` — 55
tests passed.
- `pnpm exec turbo run test typecheck
--filter=@bb/provider-bridge-protocol --filter=bb-plugin-github --force`
after rebasing — 86 provider tests and 21 GitHub tests passed; both
relevant typechecks passed.
- Repeated the new provider transport tests 25 times (250 executions)
and the complete GitHub plugin suite 10 times (210 executions) without a
failure.
- Provider bridge line coverage increased from 60.00% to 66.96%;
`runtime-json-rpc.ts` reaches 90.32%.
- GitHub plugin line coverage increased from 23.07% to 41.19%;
`server.ts` increased from 40.22% to 69.31%.
- Full app and server audit runs passed 3,092 app tests and 1,775 server
tests.

Fixes: N/A — test-coverage audit without a single tracking issue.

> AGENT GENERATED: by GPT-5
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.

github plugin latches needs-configuration on one transient gh auth failure and never re-probes

1 participant