Skip to content

Plugin RPC: bb.sdk.plugins.callRpc gives up after 75 s, but the handler keeps running and has no way to learn the caller is gone #4941

Closed

Description

@regenrek

Summary

A plugin that calls another plugin's RPC method through bb.sdk.plugins.callRpc gets BbRequestTimeoutError after 75 s. That timeout is a deliberate default, and this issue is not asking to remove it. The gap is on the other side: the server-side handler is not cancelled and has no AbortSignal in its context, so it cannot observe that nobody is waiting. The same applies when the app or the bb CLI calls an RPC method and disconnects: POST /plugins/:id/rpc/:method never reads the request's abort signal.

Code pointers are against main at 7fd6ee9 (bb 0.45.0, plugin SDK 0.6.19). The timing below was observed earlier on bb 0.45.0 with plugin SDK 0.6.15 and has not been re-run against this commit.

Reproduction

Plugin A registers an RPC method whose handler sleeps for 80 s and then writes a row:

bb.rpc.register(
  defineRpcContract({ slow: { input: z.null(), output: z.null() } }),
  {
    async slow() {
      await new Promise((resolve) => setTimeout(resolve, 80_000));
      bb.storage.database().prepare("INSERT INTO marks(at) VALUES (?)").run(Date.now());
      return null;
    },
  },
);

Plugin B calls it:

await bb.sdk.plugins.callRpc({ pluginId: "a", method: "slow", input: null, outputSchema: z.null() });
  • After 75 s B gets BbRequestTimeoutError: BB request timed out after 75 seconds. (observed at ~75.07 s in the earlier run).
  • A's handler continues, writes its row at 80 s, and the result is discarded.
  • A has no way to detect the timeout; bb plugin list shows no error for A.

Where

  • packages/sdk/src/response.ts:3 — DEFAULT_BB_REQUEST_TIMEOUT_MS = 75_000.
  • packages/sdk/src/node.ts:49-61 — createNodeTransport applies that default unless the caller passes its own fetch or timeoutMs.
  • apps/server/src/services/plugins/plugin-rpc-caller.ts:53-68 — the SDK injected into plugins for callRpc always wraps fetch in createRequestTimeoutFetch({ timeoutMs: DEFAULT_BB_REQUEST_TIMEOUT_MS }); a plugin cannot change it. The timeout is client-side only.
  • apps/server/src/routes/plugins.ts:902-977 — the RPC route never touches context.req.raw.signal.
  • apps/server/src/services/plugins/plugin-service.ts:2037-2063 — invokeRpcHandler calls handler.handler(parsedInput, { experimental_caller }); ExperimentalPluginRpcHandlerContext (packages/plugin-sdk/src/rpc-contract.ts) has only experimental_caller.
  • apps/server/src/services/plugins/plugin-runtime.ts:823-863 — invokeWrapped has no deadline.

Other plugin surfaces already pass a signal: CLI commands get ctx.signal = context.req.raw.signal (routes/plugins.ts:515-520, backend-contract.ts:930-931), agent tools get signal (backend-contract.ts:1070-1078), host RPC calls take signal and timeoutMs (packages/plugin-sdk/src/host-contract.ts:19-25). Plugin RPC handlers are the odd one out.

Expected

Either the handler is told the request is gone, or the caller can choose to wait as long as the handler needs.

Suggested direction

  1. Add experimental_signal: AbortSignal to the RPC handler context, aborted when the HTTP request disconnects. Wire context.req.raw.signal through invokeRpcHandler.
  2. Let callRpc callers choose: honour PluginRpcArgs.signal without the implicit 75 s timeout when a signal is given, or accept a timeoutMs option like host RPC does. Today PluginRpcArgs.signal exists but the injected 75 s timeout still fires.
  3. Document the 75 s default in the plugin guide so plugin authors build long operations (imports, migrations) as jobs with status polling.

Until then plugins should make long RPC handlers idempotent, because a timed-out call may still have done its work.

Activity

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

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: High · Labels: plugins, confirmed-repro.
    • Report: Reproduction and root-cause evidence — REPRODUCED, high confidence.
    • Verification: Two clean trusted-main checkouts reproduced the 75-second timeout and explicit caller cancellation. In both cases, the handler received no signal and persisted a row after the caller departed. The focused regression fails at the missing cancellation-notification assertion; its complete source and both runs are included in the report.
    • Root cause: The injected SDK cancels its fetch, but the RPC route does not propagate request cancellation; the handler context exposes only caller identity.
    • No fix PR: A root-cause repair changes the public RPC cancellation contract and requires lifetime/timeout policy decisions, outside the authorized 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