Skip to content

Uncaught PluginContextStaleError #8258

Duplicate
Duplicate

Description

@vladislavkeda3

Summary

Uncaught exception [using Opencode provider]:

plugin \"connect\" used a stale API handle — it was reloaded or disabled

Full error:

{
  "diagnosticVersion": 1,
  "kind": "uncaughtException",
  "processName": "server",
  "occurredAt": "2026-11-26T13:13:30.128Z",
  "pid": 3340763,
  "runtime": {
    "nodeVersion": "v22.23.5",
    "platform": "linux",
    "arch": "x64",
    "execPath": "/usr/bin/node"
  },
  "error": {
    "name": "PluginContextStaleError",
    "message": "plugin \"connect\" used a stale API handle — it was reloaded or disabled; re-entry happens via a fresh factory call",
    "stack": "PluginContextStaleError: plugin \"connect\" used a stale API handle — it was reloaded or disabled; re-entry happens via a fresh factory call\n    at stale (file:///home/snrs/.bb/app-versions/0.50.1/node_modules/bb-app/server/dist/start-server.js:207217:20)\n    at assertLive (file:///home/snrs/.bb/app-versions/0.50.1/node_modules/bb-app/server/dist/start-server.js:207221:28)\n    at get loopbackBaseUrl (file:///home/snrs/.bb/app-versions/0.50.1/node_modules/bb-app/server/dist/start-server.js:207576:7)\n    at Object.getLoopbackBaseUrl (file:///home/snrs/.bb/app-versions/0.50.1/node_modules/bb-app/server/dist/builtin-plugins/connect/dist/server.js?bbPluginLoad=32.32:35:36738)\n    at mt.resolveStreamOrigin (file:///home/snrs/.bb/app-versions/0.50.1/node_modules/bb-app/server/dist/builtin-plugins/connect/dist/server.js?bbPluginLoad=32.32:35:31189)\n    at Object.resolveOrigin (file:///home/snrs/.bb/app-versions/0.50.1/node_modules/bb-app/server/dist/builtin-plugins/connect/dist/server.js?bbPluginLoad=32.32:35:34287)\n    at Me.executeHttp (file:///home/snrs/.bb/app-versions/0.50.1/node_modules/bb-app/server/dist/builtin-plugins/connect/dist/server.js?bbPluginLoad=32.32:35:23782)\n    at Me.onFrame (file:///home/snrs/.bb/app-versions/0.50.1/node_modules/bb-app/server/dist/builtin-plugins/connect/dist/server.js?bbPluginLoad=32.32:35:22045)\n    at r.<anonymous> (file:///home/snrs/.bb/app-versions/0.50.1/node_modules/bb-app/server/dist/builtin-plugins/connect/dist/server.js?bbPluginLoad=32.32:35:20581)\n    at r.emit (node:events:519:28)"
  }

}

What I see in bb app:
telegram-cloud-photo-size-2-5208839421111773314-y

Versions and environment

bb 0.50.1 (desktop app, server on ubuntu 24.04)

Steps to reproduce

reload the plugin during a request

  1. Open a large thread in the web interface (thousands of events) so that the /api/v1/threads/<id>/timeline request runs for several seconds.

  2. While it is loading, run:
    bb plugin reload connect

  3. Watch the logs:

    grep -E "stale API handle|event loop stalled" ~/.bb/logs/server.*.log
    ls -lt ~/.bb/logs/process-server-uncaughtException-*.json | head
    

You should see:

[plugin:connect] service tunnel raised an uncaught exception from a stopped run:
plugin "connect" used a stale API handle — it was reloaded or disabled

and a process-server-uncaughtException-*.json file with a PluginContextStateError stack. The server will restart, and all chats will show "host daemon disconnected".

Expected vs actual

clear error message with a suggestion for how to fix it

Evidence

No response

What you ruled out

No response

Suggested priority and effort (optional)

Low

Checks

  • I reproduced this on the latest release or on main, or I say above that I could not.
  • I searched open and closed issues for the same problem.
  • If an agent wrote this, the body ends with > AGENT GENERATED and links the thread or report.

Activity

  1. added theissue type on Nov 26, 2026
  2. added
    plugins
    connect
    on Nov 26, 2026
  3. added
    partial-repro
    on Nov 26, 2026
  4. bb-slop-cop commented on Nov 26, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · High priority · Medium effort · plugins, connect.
    • Report: Reproduction and root-cause report — PARTIALLY REPRODUCED, high confidence in the disposal defect. Reproduction label: partial-repro.
    • Root cause: Disposed tunnel sessions keep their socket message listeners, allowing late frames to invoke Connect's retired origin resolver. The reported whole-server restart was not reproduced; current main already contains stale plugin errors.
    • Evidence: Both real-WebSocket regressions fail on trusted main and again in a second clean checkout, then pass after the fix. All 187 tunnel/Connect tests, relevant typechecks, and tunnel lint pass. The report discloses an unrelated full-build failure.
    • Fix: Ready PR #8259 detaches only session-owned listeners: three files, 129 changed text lines. Not merged.

    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

    connectpartial-reproplugins

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions