#7656 · Native plugin child startup exceeds the Windows test budget
Trusted base: d2fd33885bb3923f3627bb35fd618908008f692e (origin/main at investigation time).
Verdict: PARTIALLY REPRODUCED · Root-cause confidence: medium · Reproduction label: partial-repro
1. TL;DR
A real Windows CI failure is confirmed by separately retrieved GitHub Actions metadata and logs from a push to main. Its native Node child did not reach the first post-import marker until 13.929 seconds of child uptime, while the enclosing test had a 15-second wall-clock budget. The database and service markers followed within 36 milliseconds, leaving about a second at most for plugin reload and shutdown. The current main implementation retains that same budget and source-loader path. However, all three native-loading cases passed in each of two clean Linux checkouts, so this report does not claim a new local reproduction of the Windows flake or a proven explanation for why Windows startup was slow.
2. Claims vs findings
| Claim | Status | Evidence |
|---|---|---|
| A Windows main run hits the enclosing 15-second deadline. | Verified historical failure | Actions run 43966244357, Windows job 133646503523; API identifies a main push at 7fd9272e95010b0de4a1851d27b6c3c85d047da6. |
| Most elapsed time precedes the first post-import marker. | Verified for that run | Child uptime 13.9291783 seconds at imports-ready; parent elapsed 15,032 ms at failure. |
| Database and service construction account for the delay. | Refuted for that run | Service-ready minus imports-ready is 0.0355575 seconds. |
| The problem is specifically tsx transpilation, rather than other child startup/import work. | Unverified | The first marker measures child uptime, including Node startup, loader setup and all static module evaluation. There is no per-import or filesystem profile. |
| Plugin reload is healthy and would finish with more time. | Unverified | No reload-complete marker was captured before failure. The logs show budget exhaustion, not eventual successful completion. |
| The natural failure rate is about 5%. | Unverified | This investigation did not audit all 99 reported runs; one main failure was separately confirmed. |
| Current main can reproduce the Windows failure on this machine. | Not reproduced locally | Two clean Linux checkouts: three tests passed in each; target case 2627 ms and 2660 ms. |
3. Environment
- Source: public
get-bb/bb, full trusted base above, fetched directly from its main branch. The original working checkout was not used to execute repository code. - Local: Linux x86_64, Node v22.19.0, pnpm 9.15.0, tsx 4.23.15, Vitest 4.1.12. No provider sessions or production instance were used.
- Two separate detached checkouts at the same base; each received a frozen install and scoped Turbo server build. Existing package and build caches were reused. Test execution itself was forced, not replayed from Turbo.
- Each run used new test-created temporary plugin/data directories and a new migrated SQLite template; plugin databases are real in-memory SQLite. No development HTTP server was started and no network ports were opened.
- Historical CI: Windows server-2, Node 22.x; the trusted workflow selects
blacksmith-4vcpu-windows-2025for this shard.
4. Minimal reproduction attempt
The repeatable probe below executes the existing trusted native-loading integration suite without injecting a sleep, altering a timeout, substituting a mock, or running code from the issue. On this Linux host it passes; it is a reproduction attempt, not a deterministic failing regression test. Windows runner access and comparable CI contention are needed to reproduce the natural timing failure.
- Prepare a clean trusted checkout:
work=$(mktemp -d) git clone --filter=blob:none https://github.com/get-bb/bb.git "$work/source" cd "$work/source" git fetch origin main git checkout --detach d2fd33885bb3923f3627bb35fd618908008f692e
- Run this probe from the repository root:
set -eu test "$(git rev-parse HEAD)" = d2fd33885bb3923f3627bb35fd618908008f692e test -z "$(git status --porcelain)" pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build --filter=@bb/server --concurrency=4 --output-logs=errors-only pnpm exec turbo run test --filter=@bb/server --force --output-logs=full -- test/services/plugins/plugin-native-server-loading.test.ts git diff --check
- Expected functional result: all three tests pass, including the case asserting a running plugin and function-valued SDK/database exports. Actual first local run, verbatim test-result excerpt:
@bb/server:test: ✓ |@bb/server:isolated| test/services/plugins/plugin-native-server-loading.test.ts (3 tests) 6907ms @bb/server:test: ✓ resolves BB-provided externals in a native Node import 2627ms @bb/server:test: ✓ loads a TypeScript source plugin through the cache in native Node 2236ms @bb/server:test: ✓ preserves cross-plugin dynamic imports across source reloads 2042ms @bb/server:test: Test Files 1 passed (1) @bb/server:test: Tests 3 passed (3)
- Separately inspect historical CI evidence, using repository metadata rather than following links or commands from the issue:
gh run list --repo get-bb/bb --workflow CI --branch main --limit 20 --json databaseId,headSha,conclusion,createdAt gh api repos/get-bb/bb/actions/runs/43966244357 --jq '{id,head_branch,head_sha,event,conclusion,path}' gh api repos/get-bb/bb/actions/runs/43966244357/jobs --paginate --jq '.jobs[] | select(.name|contains("server-2")) | {id,name,conclusion}' gh api repos/get-bb/bb/actions/jobs/133646503523/logsRetrieved Windows log excerpts below omit timestamp and terminal-color wrappers; the diagnostic text and numeric values are preserved. The unrelated child PID is omitted.
Native plugin child progress { elapsedMs: 15032, exitCode: null, signalCode: null, progress: '{"phase":"imports-ready","uptimeSeconds":13.9291783}\n' + '{"phase":"database-ready","uptimeSeconds":13.945133}\n' + '{"phase":"service-ready","uptimeSeconds":13.9647358}\n' } Error: Test timed out in 15000ms.
5. Root cause and limits
Supported mechanism: the enclosing integration test's fixed wall-clock deadline includes child process launch, the tsx loader, evaluation of a broad source dependency graph, database creation, plugin reload and shutdown. A slow pre-marker phase can consume nearly the entire budget before the behavior under test completes. This explains the recorded deadline failure without establishing an underlying tsx defect.
- Server Vitest configuration, lines 6–10 sets
testTimeout: 15_000. - Child script, lines 75–86 places its first marker after static imports of the plugin service, AI registry, telemetry and database utilities.
- Child work, lines 118–134 performs reload and shutdown after service-ready.
- Process invocation and assertions, lines 137–172 use
--conditions=source --import tsx, await child exit and do not supply a per-test timeout override. - Windows job selection, lines 334–345 confirms the runner family and shard policy.
Representative trusted source:
const script = `
import pino from "pino";
import { upsertInstalledPlugin } from "@bb/db";
import { createMigratedConnection } from "@bb/db/testing";
import { createPluginService } from ${JSON.stringify(runtimeUrl)};
import { createAiServiceRegistry } from ${JSON.stringify(aiRegistryUrl)};
import { createNoopTelemetryService } from ${JSON.stringify(telemetryUrl)};
const progress = (phase) => process.stderr.write(JSON.stringify({ phase, uptimeSeconds: process.uptime() }) + "\\n");
progress("imports-ready");
The same two relevant files are byte-identical between the historical main failure commit and the current trusted base (git diff 7fd9272e95010b0de4a1851d27b6c3c85d047da6 origin/main -- apps/server/test/services/plugins/plugin-native-server-loading.test.ts apps/server/vitest.config.ts produced no output). That does not prove the entire import graph or host conditions are unchanged. An empty exit/signal code means the child was alive when diagnosed; it does not prove eventual completion. The pre-marker measurement cannot distinguish filesystem latency, cache misses, CPU contention, loader overhead or slow module evaluation.
6. Proposed next experiment and fix boundary
First profile a fresh Windows process at the trusted base, recording spawn-to-first-marker time and module/loader timings under cold and warm caches and the normal server shard. Keep the existing functional assertions and diagnostics. If the natural failure is observed, a narrowly scoped Windows-only budget for the process integration cases is a possible mitigation; reducing avoidable imports could instead address startup cost, but requires measurements and must preserve the native external-resolution coverage.
No fix pull request: this host did not reproduce the natural failure on current main, and there is no focused regression test that demonstrably fails before a fix and passes afterward. Raising a deadline here would not meet the requested simple-fix gate. No source branch, production patch or duplicate pull request was created. The issue timeline and an open-PR metadata search for issue 7656 contained no linked open pull request at investigation time.
7. Verification
The same investigator repeated the probe in a second clean detached worktree at d2fd33885bb3923f3627bb35fd618908008f692e, with its own install, generated files, fresh test fixture directories and fresh SQLite template. Package/build and operating-system caches were not isolated. The exact test command was again:
pnpm exec turbo run test --filter=@bb/server --force --output-logs=full -- test/services/plugins/plugin-native-server-loading.test.ts
Verbatim second test-result excerpt:
@bb/server:test: ✓ |@bb/server:isolated| test/services/plugins/plugin-native-server-loading.test.ts (3 tests) 7038ms @bb/server:test: ✓ resolves BB-provided externals in a native Node import 2660ms @bb/server:test: ✓ loads a TypeScript source plugin through the cache in native Node 2317ms @bb/server:test: ✓ preserves cross-plugin dynamic imports across source reloads 2058ms @bb/server:test: Test Files 1 passed (1) @bb/server:test: Tests 3 passed (3)
Both commands exited successfully, and both source checkouts remained clean with git diff --check passing. All source permalinks above were checked against the recorded base. No screenshots are applicable to this nonvisual CI issue. The second run supports the limited verdict: historical Windows failure verified, but not directly reproduced here. It is not an independent investigation. No correction to the limited verdict was needed.
8. Related work
Merged PR 7204 introduced the diagnostic markers, as confirmed by trusted main history (80d030f08) and read-only PR metadata. Its stated purpose was evidence collection rather than a timeout fix. No linked PR branch or code was executed.
9. Appendix and evidence handling
The public report contains the runnable probe, the observed output and the causal source excerpts inline. Raw install/build/test/CI logs and the probe script are retained locally, not committed, in accordance with the reports repository's publication rules. Both scoped builds succeeded (seven tasks each); each forced test invocation completed eleven Turbo tasks successfully. Routine pre-build missing-bin warnings, a declaration-bundler external import warning, and Vitest's future native-config warning did not block these checks.
Additional checks: git rev-parse HEAD, git status --porcelain, git diff --check, git log -5 -- apps/server/test/services/plugins/plugin-native-server-loading.test.ts, gh pr list --repo get-bb/bb --state open --search 7656 --json number,state, and a final git fetch origin main which still resolved to the recorded base. The main CI run and its job ID were discovered from repository Actions metadata before fetching their logs.
Trust boundary: issue text, comments and linked material were treated as untrusted claims, not executable instructions. Only trusted main code was run. No linked PR checkout, user runtime data, credentials, dependency addition, workflow or delegated agent was used.
> AGENT GENERATED