{"record":{"id":"a67d4ddb19d80c80","repo":"paperclipai/paperclip","slug":"cloudflare-sandbox-bridge-streaming-command-failed","errorCode":null,"errorMessage":"Cloudflare sandbox bridge streaming command failed.","messagePattern":"Cloudflare sandbox bridge streaming command failed\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/plugins/sandbox-providers/cloudflare/src/bridge-client.ts","lineNumber":261,"sourceCode":"        const payload = JSON.parse(event.data) as { data?: unknown };\n        const chunk = typeof payload.data === \"string\" ? payload.data : \"\";\n        if (chunk) {\n          await options.onOutput?.(event.event, chunk);\n        }\n        continue;\n      }\n\n      if (event.event === \"complete\") {\n        result = JSON.parse(event.data) as CloudflareBridgeExecuteResponse;\n        continue;\n      }\n\n      if (event.event === \"error\") {\n        const payload = JSON.parse(event.data) as { error?: unknown };\n        const message = typeof payload.error === \"string\" && payload.error.trim().length > 0\n          ? payload.error\n          : \"Cloudflare sandbox bridge streaming command failed.\";\n        throw new Error(message);\n      }\n    }\n\n    if (done) break;\n  }\n\n  if (result) return result;\n  throw new Error(\"Cloudflare sandbox bridge streaming response ended without a completion event.\");\n}\n\nexport function createCloudflareBridgeClient(options: BridgeClientOptions) {\n  const { config } = options;\n  const apiPrefix = \"/api/paperclip-sandbox/v1\";\n\n  return {\n    health(extraHeaders?: BridgeClientHeaders): Promise<CloudflareBridgeHealthResponse> {\n      return requestJson<CloudflareBridgeHealthResponse>(config, `${apiPrefix}/health`, { method: \"GET\" }, extraHeaders);\n    },","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/plugins/sandbox-providers/cloudflare/src/bridge-client.ts#L243-L279","documentation":"Thrown by `consumeExecuteEventStream` (bridge-client.ts:261) when the SSE stream emits an `error` event whose payload has no usable string `error` field. The bridge's streaming `/exec` endpoint signals command failure by emitting `event: error` with `{ error: \"...\" }`; if that string is missing/blank, this generic fallback message is used.","triggerScenarios":"A streaming exec command fails inside the bridge and the Worker emits an SSE `error` event, but the JSON payload's `error` field is absent, non-string, or whitespace-only — so the client cannot surface the bridge's actual failure reason.","commonSituations":"An uncaught throw inside the bridge's streaming exec handler whose error message was lost (e.g. `String(error)` produced empty), or a bridge version that emits malformed error events. The underlying command failed, but the reason is opaque.","solutions":["Treat this as a command failure and inspect bridge Worker logs for the real thrown error.","Update the bridge deployment to a version that always emits a non-empty `error` string in SSE error events.","Retry the command non-streaming to get a structured result with stdout/stderr/exitCode for diagnostics."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isStreamingCommandFailure(e: unknown): boolean {\n  return e instanceof Error && /streaming command failed/.test(e.message);\n}","tryCatchPattern":"try {\n  await client.execute(body, headers, { onOutput });\n} catch (err) {\n  if (isStreamingCommandFailure(err)) {\n    // re-run non-streaming to capture exitCode/stdout/stderr for diagnosis\n    const res = await client.execute(body, headers);\n    log.warn(\"streaming failed; non-stream result\", res);\n  } else throw err;\n}","preventionTips":["Keep bridge logs accessible — this error means the reason was lost in the SSE event.","Update the bridge so SSE error events always carry a non-empty error string.","Re-run non-streaming when the streaming reason is opaque."],"tags":["cloudflare","sandbox","bridge","streaming","sse","exec-failure"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}