Skip to content

Pending async content-script mount makes the DOM guard refuse bb's own React commits (plugin overlay container never mounts) #5836

Closed

Description

@zom-2018

Summary

While any plugin's async content-script mount promise is pending, the foreign-DOM-mutation guard treats every DOM insert on the page as made by that plugin, including bb's own React commits. On every page load React's insert of bb's plugin overlay container (<div data-bb-plugin-app-overlays>) into #root is refused, so no plugin's experimental_appOverlay content reaches the page. A plugin whose mount only waits on a timer and touches no DOM is enough to trigger it. Expected: the guard refuses only moves made by plugin code, and the overlay container mounts.

Versions and environment

  • Server: bb-app 0.46.2-nightly.39288295552.1 (npm global prefix, systemd user service), Ubuntu, Node 24
  • Clients: headless Chromium (Playwright chromium-1243) on the server host, and the Windows desktop app "bb Nightly" 0.46.2 (Windows 11). Both show it.
  • Code cited below is unchanged on main at b0bb68655adcc6cd79e495d3484f4011a0640e2e. Not checked on 0.46.1.

Steps to reproduce

  1. Create a plugin in /tmp/slow-mount-repro:

    package.json

    {
      "name": "bb-plugin-slow-mount-repro",
      "version": "0.0.1",
      "type": "module",
      "engines": { "bb": ">=0.43", "bbPluginSdk": ">=0.5.9" },
      "bb": {
        "name": "Slow mount repro",
        "description": "Async content-script mount that waits 5 s and touches no DOM.",
        "branding": { "icon": "./assets/icon.svg" },
        "server": "./server.ts",
        "app": "./app.tsx",
        "skills": []
      }
    }

    app.tsx

    import { definePluginApp } from "@get-bb/plugin-sdk/app";
    
    export default definePluginApp((app) => {
      app.contentScripts.register({
        id: "slow-mount",
        // Touches no DOM; only keeps the mount promise pending for 5 s.
        mount: () => new Promise<void>((resolve) => setTimeout(resolve, 5000)),
      });
    });

    server.ts

    import type { BbPluginApi } from "@get-bb/plugin-sdk";
    export default function plugin(_bb: BbPluginApi) {}

    plus any assets/icon.svg.

  2. bb plugin install /tmp/slow-mount-repro --yes

  3. Load the app in a fresh browser profile and, after it settles, run in the console:
    document.querySelector('[data-bb-plugin-app-overlays]')

  4. bb plugin remove slow-mount-repro --yes and repeat step 3.

Expected vs actual

With the plugin installed (2 of 2 loads):
[bb] plugin "slow-mount-repro" tried to move <div> out of React's tree. The move was blocked so the app does not crash when that node is later removed or reordered.
document.querySelector('[data-bb-plugin-app-overlays]')  -> null

Plugin removed (1 of 1 load): no warning; the query returns the element.

Expected: no warning, since the plugin never touches the DOM, and the overlay container is mounted.

The warning's stack is React's commit, not plugin code (captured over CDP):

recordRefusedMove   index-C4VnRLIO.js 397:18294
refusePluginReparent index-C4VnRLIO.js 397:18591
guarded insertBefore index-C4VnRLIO.js 397:20429
(react-dom commit)  boot-vendor-CF34wNtG.js 7:93783, 7:104851, 7:102265, …
node:            <div data-bb-plugin-app-overlays class="contents"> (children: plugin roots for auto-answer, beautiful-chat, …)
attemptedParent: <div id="root">
actualParent:    null

Evidence

Observed: the refusal and the missing container, above.

Cause (my reading of the code, not a confirmed fix):

  • runWithPluginDomIsolationAsync increments the global isolationDepth and decrements it only after the mount promise settles. Everything that runs on the main thread in between, including React commits, sees isolationDepth > 0.
  • refusePluginReparent then refuses inserting a fresh React-owned node (parentNode === null) into a parent that has no React fiber. #root is the React root container, so it has none. Portal containers that bb creates outside React would match the same way.
  • Content-script mounts go through it in plugin-frontend.ts. Async mounts are documented as allowed and are time-boxed to 10 s, so the window can be up to 10 s per plugin.

Real-world trigger: agentic-mermaid awaited fetching bb's chunks and importing Mermaid inside mount, which hit this on every load. Plugin-side workaround: bottlebrushes/bb-plugin-agentic-mermaid#2. Every plugin with a non-trivial async mount is exposed.

Measured with headless Chromium driven over CDP: fresh profile, Page.navigate, then the query above about 28 s later. Load-to-mount took about 23 s on this host.

Possible direction: keep isolation only around synchronous plugin execution, which callback and timer wrapping already cover, instead of across the awaited promise.

What you ruled out

Suggested priority and effort

Medium. It silently hides every plugin's app overlays whenever any installed plugin has a slow async mount, and users cannot see why. Plugin authors can work around it. Effort probably Low.

I could not link a bb thread: this came from a local agent debugging session on a self-hosted server.

AGENT GENERATED

Activity

  1. added theissue type on Oct 20, 2026
  2. added
    plugins
    confirmed-repro
    on Oct 20, 2026
  3. bb-slop-cop commented on Oct 20, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority Medium · Effort Medium · plugins.
    • Reproduction and root-cause report: REPRODUCED, high root-cause confidence; reproduction label: confirmed-repro.
    • Evidence: A real-React/jsdom regression fails in two clean trusted-main checkouts; the settled-mount control passes. All 21 existing focused tests pass. Full browser/desktop verification was unavailable.
    • Root cause: App-global isolation remains active across the awaited plugin mount, misattributing unrelated host React insertions to the plugin and leaving the overlay host detached.
    • No PR: Shortening isolation would remove existing, tested post-await protection. Correct execution ownership needs a design decision, outside the simple-fix gate.

    AGENT GENERATED

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