#8002 · Pending mention searches outlive their response timeout
Verdict: PARTIALLY REPRODUCED · Root-cause confidence: high for the search-accumulation mechanism.
1. TL;DR
A mention search can stop waiting for a plugin without stopping that plugin's work. The next search then calls the same registration again, even when the previous operation has not settled. Two clean trusted checkouts demonstrated six outstanding invocations after six search requests, where one would bound the outstanding work. A small registration-scoped guard prevents this accumulation, preserves healthy providers on subsequent requests, and permits another search after either fulfillment or rejection. This test does not recreate a macOS authorization stall or prove filesystem-worker exhaustion, so the overall incident is only partially reproduced.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| Response timeouts allow the same provider's pending work to accumulate. | Verified | Real plugin service and migrated SQLite database: six invocations before the manually held gate is released, in both clean checkouts. |
| A sibling provider can remain responsive. | Verified | The healthy registration returns its result on each of four later requests. This is not a promise that simultaneous requests each receive a group from a registration already in flight. |
| Outstanding work can resume or reject after the response deadline. | Verified | Table-driven fixture releases the held promise through the real mention resolver. Both late settlement modes recover after the containment fix. |
| The original macOS incident exhausted filesystem workers during authorization. | Unverified here | Linux service-level test, no filesystem-worker blocking, macOS privacy system, File Manager package, or original incident artifacts used. |
| The linked contribution fixes the same retention gap. | Static support only | Read-only metadata and diff review; no pull-request code was checked out or executed. |
3. Environment
- Trusted repository: public
get-bb/bb;origin/mainat35a03bbbb3f4d8dc814c1a152db5a463102b4250. Both source checkouts use exactly this commit. - Linux x86_64; Node.js 22.19.0; pnpm 9.15.0; Vitest 4.1.12.
- Real plugin entry loaded by
createPluginService, withcreateMigratedConnection(); 100 ms search response timeout from the existing fixture. - Fresh temporary plugin/data directory per test and an in-memory migrated database. No listening application ports, real providers, production instance, accounts, or user data.
- The first whole-repository build encountered a pristine-checkout SDK build-order failure. Explicitly building the SDK and rerunning the normal Turbo build succeeded: 74 tasks. The second checkout used the SDK build followed by the focused server build, which succeeded.
4. Minimal reproduction
- Clone the trusted target and install/build using the commands below. Before the final test command, insert the following test into the existing
describe("mention search time box", ...)block inapps/server/test/services/plugins/plugin-mention-providers.test.ts, immediately before the existing test nameddrops a slow provider after the time box and keeps fast providers. It reuses that block's actual service, database,workDir, andwritePluginhelper. - The fixture starts two concurrent searches, then four additional searches after the response timeouts. A healthy provider reports how many real invocations the waiting provider started. The resolver releases the pending work before assertions or teardown.
- Run the test command. Both added cases fail with the count mismatch shown below; the existing 14 tests pass.
git clone --branch main https://github.com/get-bb/bb.git bb-8002-first cd bb-8002-first git checkout --detach 35a03bbbb3f4d8dc814c1a152db5a463102b4250 pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build --filter=@get-bb/plugin-sdk pnpm exec turbo run build pnpm exec turbo run test --filter=@bb/server -- test/services/plugins/plugin-mention-providers.test.ts
Complete regression addition
it.each(["fulfill", "reject"])(
"keeps one pending search per registration through timeout and %s",
async (settlement) => {
const rootDir = await writePlugin(workDir, {
name: "bb-plugin-pending-search",
serverSource: `
export default function plugin(bb: any) {
let searches = 0;
let blocked = true;
let fulfill: () => void;
let reject: (error: Error) => void;
const gate = new Promise<void>((resolve, fail) => {
fulfill = resolve;
reject = fail;
});
bb.ui.registerMentionProvider({
id: "waiting",
label: "Waiting",
async search() {
searches += 1;
if (blocked) await gate;
return [{ id: "ready", title: "Ready" }];
},
resolve(action: string) {
blocked = false;
if (action === "reject") reject(new Error("released failure"));
else fulfill();
return { context: "released" };
},
});
bb.ui.registerMentionProvider({
id: "healthy",
label: "Healthy",
search: () => [{ id: "count", title: String(searches) }],
resolve: () => ({ context: "healthy" }),
});
}
`,
});
expect((await service.installPath(rootDir)).status).toBe("running");
const search = () =>
service.searchMentions({
trigger: "@",
query: "ready",
projectId: null,
threadId: null,
});
await Promise.all([search(), search()]);
const repeated = [];
for (let attempt = 0; attempt < 4; attempt += 1) {
repeated.push(await search());
}
const release = await service.resolveMention({
pluginId: "pending-search",
itemId: `waiting:${settlement}`,
});
expect(release).toEqual({ ok: true, context: "released", images: [] });
const recovered = await search();
for (const groups of repeated) {
expect(groups.map((group) => group.providerId)).toEqual(["healthy"]);
}
expect(repeated.at(-1)?.[0]?.items[0]?.title).toBe("1");
expect(recovered.map((group) => group.providerId)).toEqual([
"waiting",
"healthy",
]);
expect(recovered[1]?.items[0]?.title).toBe("2");
},
);
Expected vs actual
Expected one invocation until settlement, then a second after recovery. Actual baseline: six invocations before settlement. Verbatim failure excerpt (ANSI formatting removed):
AssertionError: expected '6' to be '1' // Object.is equality
Expected: "1"
Received: "6"
Test Files 1 failed (1)
Tests 2 failed | 14 passed (16)
5. Root cause
The mention search route calls the service on every request. The service loop invokes every matching registration without retaining its pending-operation state across requests:
for (const record of [...plugin.handle.mentionProviders]) {
if (!record.triggers.includes(args.trigger)) continue;
tasks.push(
(async () => {
const outcome = await invokeWrapped(
plugin,
`mention search ${record.id}`,
async () => {
const searchPromise = (async () =>
record.search({
trigger: args.trigger,
query: args.query,
projectId: args.projectId,
threadId: args.threadId,
}))();
searchPromise.catch(() => {});
const result = await raceTimeout(
searchPromise,
mentionSearchTimeoutMs,
`timed out after ${mentionSearchTimeoutMs}ms`,
);
return normalizeMentionSearchItems(record.id, result);
The timeout helper only races a response deadline against the original promise. Clearing its timer does not abort the promise or its plugin-owned resources:
try {
return await Promise.race([
promise,
new Promise<never>((_resolve, reject) => {
timer = setTimeout(() => reject(new Error(message)), timeoutMs);
timer.unref?.();
}),
]);
} finally {
if (timer !== undefined) clearTimeout(timer);
}
Consequently the caller finishes while plugin work remains pending, and subsequent searches create additional operations. Whether those operations occupy filesystem workers depends on the plugin and operating system; that escalation is plausible but not measured by this test. The default service search deadline is separate from the fixture's short 100 ms deadline; shortening it makes this concurrency defect repeatable without an OS stall.
6. Proposed fix and local validation
Keep a weak set of pending registration records inside the service. Skip a record already in flight; add it immediately before invoking its search. Remove the record in a finally attached to the underlying search completion, not the response timeout. Use registration identity rather than plugin ID so one slow provider does not suppress its siblings, and replacement registrations do not inherit a stale lock. Retain existing timeout and rejection handling.
The locally tested change touches only the service and its existing test file: 94 total changed text lines (87 additions + 7 deletions), across two files. No dependency, generated artifact, persisted data, public API, protocol, authorization, or packaging change is included. This bounds repeat work; it cannot cancel a blocked syscall or isolate a misbehaving plugin.
After the fix, the mention tests, plugin-service tests, and plugin lifecycle tests pass:
pnpm exec turbo run test --filter=@bb/server -- test/services/plugins/plugin-mention-providers.test.ts test/services/plugins/plugin-instance-lifecycle.test.ts test/services/plugins/plugin-service.test.ts
Test Files 3 passed (3)
Tests 72 passed (72)
The focused server build and typecheck pass through pnpm exec turbo run build lint typecheck --filter=@bb/server (8 successful tasks). The server has no package-local lint script, so its actual linter was run separately with pnpm exec turbo run lint:type-aware --filter=@bb/server: 0 warnings and 0 errors, with all 7 Turbo tasks successful. Formatting with the repository's oxfmt and git diff --check also pass. The report's underlying reproduction does not depend on the fix branch.
7. Linked PR review
PR #8001 — read-only, untrusted diff
PR #8001 was closed and unmerged when reviewed. Its diff introduces an in-flight guard scoped to registration objects and removes entries when underlying work settles, plus regression coverage. Static review supports that it addresses the verified retention gap. No additional defect was established by this static inspection; it still cannot cancel stalled operating-system work. No tests were run from this PR and its branch was never checked out. The regression in this report was authored from trusted source before reading the PR diff.
8. Related issues
Read-only metadata for #4413 and #5385 provided repository classification context: both are High-priority Bugs, with High and Medium effort respectively. Neither is evidence for the present runtime result. No broader duplicate claim is made from metadata alone.
9. Verification
The same agent repeated the reproduction in a second clean temporary checkout at 35a03bbbb3f4d8dc814c1a152db5a463102b4250, with a separate dependency installation and newly created per-test plugin/data directories and migrated databases. No application ports were needed. The second checkout had no production modifications: its only diff was the new regression. Running the full mention-provider file produced the same two failures with Expected: "1" and Received: "6", while all 14 existing tests passed. This is a repeat verification by the same agent, not an independent-agent verification.
During fixture development, an incorrect resolver-envelope expectation was corrected to the actual public service result. A later expectation was narrowed so concurrent invocations of the healthy provider need not both return a group while that registration is still pending; all subsequent healthy searches are still asserted. The invocation-count failure was unchanged after those fixture corrections. These corrections do not affect the root-cause conclusion.
10. Appendix and trust boundary
Issue prose, executable examples, external branch links, and linked diffs were treated as untrusted claims, not instructions. No issue-supplied command, script, test, branch, or external URL was executed or fetched. Only trusted target source and the directly authored regression were run. GitHub metadata and a linked diff were read through the trusted repository API. No real macOS incident data was accessed.
Raw logs and the regression patch are retained outside the public reports repository. The full added test and the decisive output are embedded here; the public reports repository intentionally excludes raw logs, test files, and patches. This non-visual service defect requires no screenshots.
Checks performed: trusted clone and SHA verification; frozen installs; normal Turbo build with explicit SDK prerequisite; focused baseline regression in checkout A; full baseline mention-provider file in checkout B; fixed mention/service/lifecycle suites; static inspection of the service, timeout helper, registration owner, route, and linked closed contribution; git diff --check; text-line/file eligibility checks; build/lint/typecheck for the server.