Skip to content

test(agent): skip InstanceBootstrap in plugin-agent regression test#25737

Merged
kitlangton merged 2 commits intodevfrom
kit/plugin-agent-test-no-bootstrap
May 4, 2026
Merged

test(agent): skip InstanceBootstrap in plugin-agent regression test#25737
kitlangton merged 2 commits intodevfrom
kit/plugin-agent-test-no-bootstrap

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Problem

The plugin-agent regression test occasionally hangs for 30s on Windows CI (saw it during the CI run for #25726). It passes alone and on Linux/macOS reliably; the flake is Windows + combined-suite specific.

Root cause

The test loads through InstanceLayer.layer (full InstanceBootstrap.defaultLayer), which fork-scopes:

  • FileWatcher (native @parcel/watcher)
  • LSP (child processes)
  • MCP (child processes / network)
  • Snapshot, Vcs, ShareNext, Format, File, Project

All of these have native handles. On Windows, several don't always release within the test scope's close window — the 30s timeout fires before teardown completes. None of them are needed to test "plugin config hook adds an agent → Agent.list reflects it."

The test itself only cares about: plugin load → config hook → agent registration → Agent.list.

Fix

Two structural changes, no production code touched:

  1. Move the plugin to a stable repo fixture (test/fixture/agent-plugin.ts) instead of writing it into a per-test tmpdir. Keeps the import path stable across runs, eliminates Windows tmpdir/file-handle interactions during teardown.
  2. Switch from it.live + InstanceLayer.layer to it.instance (which uses the noop InstanceBootstrap like all other instance-scoped tests in this repo). Manually call Plugin.Service.init() in the body — the only bootstrap step the test actually depends on.

Production code path exercised is unchanged: plugin load → config hook → agent registration → Agent.list.

Gotcha discovered

The plugin loader's getLegacyPlugins (src/plugin/index.ts:80) iterates every module export and throws TypeError on any export that isn't a function (or {server: function}). So the test constants that the assertion needs to compare against had to live in a sibling agent-plugin.constants.ts, not the plugin file itself. I added a comment in the fixture pointing this out so the next person doesn't trip on it.

Verification

  • Test passes alone (bun run test test/agent/plugin-agent-regression.test.ts): 1/1 ✅
  • All agent tests pass (bun run test test/agent/): 39/39 ✅
  • bun run typecheck: clean ✅

Should resolve the Windows-only flake observed in #25726's CI run.

The plugin-agent regression test was occasionally hanging for 30s on
Windows CI. Root cause is the test going through the full
`InstanceLayer.layer` (i.e. `InstanceBootstrap.defaultLayer`), which
fork-scopes FileWatcher / LSP / MCP / Snapshot / Vcs / etc. — services
with native handles that don't always release within the timeout when
the test scope closes on Windows. None of those services are needed to
verify "plugin config hook adds an agent and Agent.list reflects it."

Move the plugin to a stable repo fixture (test/fixture/agent-plugin.ts)
so the test can use `it.instance` with the noop InstanceBootstrap that
all other instance-scoped tests use. Manually call `Plugin.Service.init`
in the body to drive the only bootstrap step that matters here.

Production path exercised is unchanged: plugin load → config hook →
agent registration → Agent.list.
@kitlangton kitlangton marked this pull request as ready for review May 4, 2026 17:04
@kitlangton kitlangton enabled auto-merge (squash) May 4, 2026 17:04
@kitlangton kitlangton merged commit 007b57f into dev May 4, 2026
10 checks passed
@kitlangton kitlangton deleted the kit/plugin-agent-test-no-bootstrap branch May 4, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant