Repository navigation
Description
Three related requests we collected while building a sidebar plugin that aggregates data from other plugins and gates some RPC methods by caller. Each is small on its own; together they describe the missing "plugins talking to plugins" edges of the SDK. Code pointers are against main at 7fd6ee9 (bb 0.45.0, plugin SDK 0.6.19); the behaviour was first noticed on plugin SDK 0.6.15 and re-checked against the current code.
1. An RPC handler cannot refuse a call with a status other than 500
PluginRpcErrorCode has invalid_json | invalid_input | handler_error | invalid_output | non_json_result | unknown_method (packages/plugin-sdk/src/rpc-contract.ts). For handler outcomes the route maps invalid_input to 400 and everything else to 500 (apps/server/src/routes/plugins.ts:962-977). The 403s that exist are infrastructure-level: untrusted browser origin (apps/server/src/browser-request-guard.ts:188-192) and a bad plugin caller token (routes/plugins.ts:912-920). A handler itself has no way to produce one.
So a handler that uses experimental_caller to refuse a call has two options: throw (HTTP 500, code: "handler_error"; the throw is also counted in handlerStats.errorCount and written into the plugin's statusDetail as rpc <method> failed: ..., apps/server/src/services/plugins/plugin-runtime.ts:847-853), or encode the refusal inside a 200 result, which every caller then has to special-case.
Clients would already carry a better code: useRpc copies message, code and issues from a structured error body onto the thrown error (apps/app/src/lib/plugin-sdk-hooks.ts:172-190), and BbHttpError has code and status (packages/sdk/src/response.ts:82-92). What is missing is a way for the handler to say "forbidden" that the route maps to 403 and does not treat as a crash.
Small repro:
bb.rpc.register(contract, {
adminOnly(_input, context) {
if (context.experimental_caller.kind !== "plugin") throw new Error("forbidden");
return null;
},
});Calling adminOnly from the app yields HTTP 500 { code: "handler_error", message: "forbidden" }, bb plugin list shows one more handler error, and statusDetail reads rpc adminOnly failed: forbidden.
Suggestion: let a handler throw a typed error (for example new PluginRpcRefusal({ code: "forbidden", message }), maybe also not_found/conflict) that the route maps to 403/404/409, is excluded from errorCount/statusDetail, and reaches useRpc and bb.sdk.plugins.callRpc callers with that code.
2. useRealtime delivers only the calling plugin's channels
bb.realtime.publish(channel, payload) broadcasts { pluginId, channel, payload } to every connected client (packages/plugin-sdk/src/backend-contract.ts:876-883, apps/server/src/ws/hub.ts:897-905). The app-side hook keeps only signals whose pluginId equals the caller's own (apps/app/src/lib/plugin-sdk-hooks.ts:242-258). This is the documented V1 design, not a defect; the request is to extend it.
A plugin whose UI shows another plugin's data (a sidebar section over plugin B's items, a status widget over bb-account's sign-in state, which bb-account already publishes on its own channel in plugins/bb-account/src/plugin.ts:43-60) currently has to refresh on an interval or expose a server-side relay in its own backend, although the signal it needs already reaches the browser.
Small repro: plugin B calls bb.realtime.publish("items-changed", {...}); plugin A's component calls useRealtime("items-changed", handler). handler never runs, because the signal carries pluginId: "b".
Suggestion: experimental_useRealtime(channel, handler, { pluginId }) (or a pluginId option on useRealtime) so a plugin can opt into another plugin's channels. Publishing stays owner-only; subscribing to a named plugin's channel is read-only and matches the existing "every client receives every signal" transport.
3. experimental_discoverRpc has no signal
PluginsArea.experimental_discoverRpc(args?: PluginRpcDiscoveryQuery) accepts only pluginId and method (packages/sdk/src/areas/plugins.ts:241-243, packages/server-contract/src/api/plugins.ts:555-561), and the implementation calls requestParsed without signal (areas/plugins.ts:408-417). The other read-style methods in the same area take signal?: AbortSignal (callRpc, list, getSettings, getSource, checkUpdates, listUpdateResults, experimental_getSafeMode, catalog.search/status, marketplaces.list/refresh; areas/plugins.ts:100-190); mutations such as enable, install or reload do not, which is fine. Discovery is a read that typically runs inside a React query or a refresh loop, so it is the one request there that cannot be cancelled on unmount.
Small repro: useQuery({ queryKey: [...], queryFn: ({ signal }) => sdk.plugins.experimental_discoverRpc({ method: "x" /* no signal slot */ }) }) — the request outlives the component.
Suggestion: add signal?: AbortSignal to the discovery args and pass it through, same as callRpc.
Expected
Plugins can (1) refuse an RPC call with a proper status that is not logged as a crash, (2) react to another plugin's realtime signals, and (3) cancel discovery requests like the other read calls.
Adjacent, not duplicates: #1632 (open; multipart uploads and parameterized paths for plugin HTTP routes), #4272 (closed; a plugin page did not refetch after a realtime reconnect).
Activity
bb-slop-cop commentedon Oct 5, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotApplied and verified: Type: Feature · Priority: Medium · Effort: High · Labels:
plugins. All classification values were previously unset; no existing values were replaced.Reviewed trusted
origin/mainatf7f106dab: the RPC error contract, own-plugin realtime filtering, and discovery arguments implement the current interfaces. The requested capabilities extend those interfaces rather than demonstrate a regression. Medium priority reflects limited scope and available workarounds; high effort reflects coordinated public SDK, runtime, and app contract changes.No reproduction report or pull request: the final Type is Feature, so this rule skips bug reproduction and automatic fixes.
Accept an abort signal in experimental_discoverRpc (#5163)
kr3t3n commentedon Oct 13, 2026
A concrete case for point 2 (
useRealtimeis own-plugin only), with numbers and the workaround we use now.Setup. Two plugins. Labels Pro stores thread labels and publishes every change on its
labelschannel. Sidebar Pro replaces the thread list and shows label chips and a label filter. About 4,900 live threads, 32 labels and 7,000 assignments.What happened. Sidebar Pro's frontend subscribed to
labels, butuseRealtimedrops signals whosepluginIdis not its own (onPluginSignalfilter in the app's realtime hook). The signal reached every browser and was discarded. The only working update path was a poll: onelistLabelscall plus onelistThreadsByLabelcall per label, every 30 seconds, per open window. Labels Pro served about 22,000 RPC calls in five hours, and each poll rebuilt the label map, which re-ran the list filters and redrew every row.Workaround. A server-side relay:
subscribeChanges({ method })on Labels Pro throughbb.sdk.plugins.callRpc. Labels Pro checksexperimental_caller.kind === "plugin"and stores the subscription.Measured result: one bulk read on load, label chips update about 600 ms after a write, and no calls while idle. It works, but every consumer plugin now needs a server entry, an RPC method and a subscription protocol only to forward a signal the browser already received.
Request. Let a frontend subscribe to another plugin's channel, for example
useRealtime(channel, handler, { pluginId: "labels-pro" }). If open subscription is too broad, an allowlist that the publishing plugin declares in its manifest would cover this case.Declare live-data tags on route contracts and refresh through tagged …
Let plugins read and write live data through core's tagged queries (#…