Skip to content

Plugin reload: host rebuilds plugin artifacts into the deployed root, and orphaned services survive with closed handles while reload reports exit 0 #2029

Closed

Description

@pixexid

Two related defects observed while operating a path-installed plugin from a deployed git worktree, on bb 0.39.0 / plugin SDK 0.4.1, macOS. Both are reproducible and both were measured rather than inferred.

1. The host rebuilds plugin frontend artifacts into the deployed root during load

start-server.js (installed app bundle, ~line 310745) rebuilds dist/app.js and dist/app.css during plugin loading when a source file's mtime exceeds dist/app.js, calling buildPluginApp() directly into the plugin's root (~line 310808).

For a plugin deployed from a git checkout, this modifies tracked, committed artifacts in place. The rebuild embeds absolute paths, so the output differs from the committed bytes:

-// src/provider-marks.ts
+// .bb/worktrees/env_ikf7t4jf3k/bb-collab/src/provider-marks.ts

Observed across three deploys. server.js is never rebuilt by this path; only app.*. Timing: server.js at 01:53:08 from the checkout, app.css/app.js at 01:53:21 — about 13 seconds after the reload returned.

Why it matters: we verify the deployed artifact against its commit before loading it, so we know what actually runs. This silently invalidates that check after the load, and the failure surfaces on the next deploy as unexplained drift. It also means a deployed checkout is permanently dirty between deploys, and the integrity check cannot distinguish "someone hand-edited an artifact" from "the host rebuilt it" — which is the distinction it exists to draw.

Workaround we now use: ensure dist/ mtimes are newer than all sources after advancing the checkout, so the gate is unsatisfied. This works, and it depends on an undocumented internal condition.

Ask: don't write into a plugin's root during load — or make the rebuild reproduce the committed bytes (build-location independent) — or expose the condition so a deployer can reason about it.

2. bb plugin reload leaves orphaned services running and still reports exit 0

A reload left the plugin's previous lane-watcher service resident. It survived holding a reference to the now-closed database connection and threw on every tick:

capacity-interval-unreadable:TypeError: The database connection is not open

845 occurrences over the following 16 minutes, roughly one every 5 seconds. Meanwhile:

  • bb plugin reload returned exit 0
  • bb plugin list showed degraded (service lane-watcher did not stop)
  • the plugin's CLI command surface was entirely gone — bb collab … returned error: unknown command 'collab'

A second reload cleared the degraded label and restored the command surface. bb plugin disable followed by enable fully cleared the orphan.

Ask: a reload that cannot stop a service should fail its own exit code rather than reporting success. An exit code that says "the loader ran" while the plugin is unusable is the wrong signal for an automated deploy, which is exactly where reload is used.

Smaller, related

bb plugin list reported running for a period while a component was still dead. Degraded at least tells the truth; running over a broken component is worse for an operator deciding whether to act.

Happy to help

We can supply logs, exact timings, or test against a patch. The workaround for (1) is in our deploy procedure, so neither is blocking us — but both cost real debugging time, and (2) cost fifteen minutes of unrecorded data before anyone thought to look past the exit code.

Activity

  1. added theissue type on Aug 20, 2026
  2. added
    plugins
    cli
    on Aug 20, 2026
  3. SawyerHood commented on Aug 20, 2026

    @SawyerHood
    Collaborator

    Reproduction & root-cause report: https://get-bb.github.io/reports/issues/2029.html

    • Verdict: REPRODUCED · root-cause confidence: high
    • Root cause (short): Path-install frontend artifacts are by design a host-owned cache written into the plugin root (on install unconditionally, and on every load when any source mtime > dist/app.js or app.meta.json sdkVersion differs/unparseable), and reload() returns void so POST /plugins/reload answers ok:true and the CLI exits 0 even when stopServices hung the plugin into degraded/unloaded with its DB handles closed under the orphaned service.
    • Proposed fix: Defect 2: make PluginService.reload(id) return the per-plugin outcome and have POST /plugins/reload answer ok:false with the status detail whenever a targeted plugin ends degraded/error/incompatible/missing (or kept its previous instance), so bb plugin reload exits 1 via the existing !ok path; no daemon wire change. Defect 1: build path-install app/host artifacts into a host-owned cache under the data dir (add an outDir to buildPluginApp/buildPluginHost, serve getAppAsset from it) instead of /dist; at minimum skip the unconditional install-time build when a compatible dist/app.meta.jso…
    • Caveats: Revision: added step0-fixture-setup.sh (fixture assembly; provider mark reset to v1 so step 2's sed works), made all step scripts derive CLI/dev log from BB_WORKTREE (BB_CLI/BB_DEV_LOG overrides) and documented that in the HTML, added dist/server.js to the step 4/5 stat output, explained the 'built with SDK unknown' log (hand-edited meta rejected by parsePluginArtifactMeta), and re-ran steps 0-5 p…

    The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at the base commit, and repro artifacts. It was independently re-run by a second agent (see its Verification section).

    AGENT GENERATED: by Claude Opus 5

  4. added
    confirmed-repro
    on Aug 20, 2026
  5. self-assigned this
    on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

cliconfirmed-reproplugins

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions