Skip to content

Reloading a plugin interrupts the new instance's pending interactions (plugin-disposed), so startup requestInput forms are lost #4432

Closed

Description

@MPIsaac-Per

Summary

When a plugin is reloaded, bb runs the new instance's factory before disposing the previous instance. Disposal then calls interruptPluginInteractions(pluginId), which interrupts every pending interaction for that plugin id, including forms the new instance has just raised. A plugin that re-raises its pending forms at startup (for example, approvals that must survive a restart) loses them on every bb plugin reload or plugin update. Its promise resolves { outcome: "cancelled", reason: "plugin-disposed" } milliseconds after the form is created.

Versions and environment

  • bb-app 0.43.3 (npm global install; desktop-v0.43.3, e865697). I checked the same order on main at 4354b88.
  • Linux x64, Node 22. Local-path plugin.

Steps to reproduce

  1. Create a thread and note its id, then echo <threadId> > /tmp/reload-probe-thread.
  2. Install this local plugin:
// server.ts
import { readFileSync } from "node:fs";
export default function plugin(bb) {
  const threadId = readFileSync("/tmp/reload-probe-thread", "utf8").trim();
  void bb.ui
    .requestInput({ threadId, rendererId: "reload-probe", title: "Reload probe", payload: {} })
    .then((result) => bb.log.info(`reload-probe result: ${JSON.stringify(result)}`));
}
  1. Confirm the form is pending on the thread (bb thread interactions list <threadId>).
  2. Run bb plugin reload <pluginId>.
  3. List the thread's pending interactions again, and check the plugin log.

Expected vs actual

  • Expected: after the reload, the new instance's form stays pending. Only the old instance's form is interrupted.
  • Actual:
    • there are no pending interactions;
    • the form raised by the new instance's factory is interrupted with status_reason = "plugin-disposed" about 10 ms after creation (observed: created 21:30:53.043, interrupted 21:30:53.056);
    • the new instance's promise resolves {"outcome":"cancelled","reason":"plugin-disposed"}.

Evidence (code, desktop-v0.43.3)

  • apps/server/src/services/plugins/plugin-runtime.ts: loadOne calls runFactoryTimeBoxed(...) (L1627) and only afterwards await disposePluginInstance(row.id, previous) (L1684).
  • disposePluginInstance calls deps.pendingInteractions?.interruptPluginInteractions(id) (L1756).
  • That lands in apps/server/src/services/interactions/pending-interactions.ts L729-736, which calls interruptPendingInteractionsForPlugin(db, { pluginId, statusReason: "plugin-disposed" }) (packages/db/src/data/pending-interactions.ts L361). The update matches on plugin id only, with no instance or generation.
  • main at 4354b88 has the same order (runFactoryTimeBoxed L1863, then disposePluginInstance(row.id, previous) L1921) and the same plugin-id-wide interrupt.

What I ruled out

  • Not a timeout: the default requestInput timeout is 10 minutes, and the interrupt happens within milliseconds of the reload.
  • Not the plugin's own abort signal: no signal was passed.
  • Not a duplicate: I found no existing bb issue about reload or plugin-disposed.
  • Plugin-side workaround: re-raising on reason: "plugin-disposed" from the new instance, with a process-wide "newest instance owns it" guard so the old instance doesn't also re-raise, restores the form. That works, but every plugin has to know about the ordering.

Suggested fix

Either scope the interrupt to interactions created by the instance being disposed (store an instance or generation id on the interaction row and filter on it), or dispose the previous instance before running the new factory.

Note: timeout default is undocumented in the guide

The plugin authoring guide's bb.ui.requestInput section (plugins/bb-guide/skills/bb-plugin-authoring/references/backend-cli-agents.md) doesn't say that timeoutMs defaults to 10 minutes (max 1 hour). Only the SDK type comment in backend-contract.ts says so. A form a user doesn't answer within 10 minutes silently ends cancelled/timeout. Together with the reload behaviour above, this makes long-lived approval forms easy to lose. One sentence in the guide would help. I'm happy to split this into a separate docs issue if preferred.

AGENT GENERATED

Activity

  1. added theissue type on Sep 30, 2026
  2. added
    plugins
    confirmed-repro
    on Sep 30, 2026
  3. SawyerHood commented on Sep 30, 2026

    @SawyerHood
    Collaborator

    Verified report: https://get-bb.github.io/reports/issues/4432.html

    REPRODUCED through the real plugin reload service and interaction database in two clean checkouts at the same main SHA, repeated by the same agent. After the first ordinary question is submitted, reloading admits the new factory question but old-instance cleanup cancels it with plugin-disposed. The settled-first-form condition matters: leaving the old form pending hits the current same-thread admission guard instead. Browser rendering was not tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reproplugins

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions