Skip to content

Run cleanup hooks before discarding failed plugin candidates - #8028

Closed
bb-slop-cop[bot] wants to merge 1 commit into
mainfrom
slopcop/issue-8025
Closed

bb-slop-cop[bot] wants to merge 1 commit into
mainfrom
slopcop/issue-8025

Conversation

@bb-slop-cop

@bb-slop-cop bb-slop-cop Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

🚨 SLOP COP 🚨 · new-issue-autopilot

Human comments

What was wrong

Failed plugin candidates were invalidated without running their registered cleanup hooks. Plugin-created timers consequently outlived both the failed load and service shutdown, repeatedly using stale API handles. Reproduced twice against trusted origin/main at 796cdcc0f4bf8a55e23664035c54e8db6fe9d272.

Report: https://get-bb.github.io/reports/issues/8025.html

What changed

Share the existing reverse-order, per-hook error-isolated cleanup runner between normal disposal and failed-candidate discard. Await candidate hooks before closing databases or invalidating the API; retain the previous live instance after a failed reload. Add a service-level regression covering initial host-build rejection, initial factory failure, and failed reload factory cleanup, including asynchronous hooks and a throwing hook.

Two files; 207 changed text lines: 197 additions and 10 deletions. No dependencies, generated files, stored-data changes, public API, or wire changes. Diagnostic-report rate limiting remains outside this fix.

How you verified

  • The new three-case regression fails on unchanged production code in two clean checkouts: missing hooks, surviving timers, and captured stale-handle errors.
  • Regression plus existing instance lifecycle: pnpm exec turbo run test --filter=@bb/server -- test/services/plugins/plugin-candidate-cleanup.test.ts test/services/plugins/plugin-instance-lifecycle.test.ts — 16 tests passed.
  • Related background, host-build-policy, failure-log, service, install, version-reload, reload-collection, and provider-registration suites — 159 tests passed. Total: 175 passed across 10 files.
  • pnpm exec turbo run lint typecheck --filter=@bb/server passed.
  • git diff --check passed; git diff --numstat origin/main confirms 207 text lines and no binary changes.

Fixes #8025

AGENT GENERATED

@ymichael

Copy link
Copy Markdown
Collaborator

Closing in favour of #8029, which fixes the same issue (#8025). We'll fold any useful parts of this change into #8029 during review.

@ymichael ymichael closed this Nov 23, 2026
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.

Plugin load that fails after its server factory runs never runs bb.onDispose, so timers and subscriptions leak

2 participants