{"record":{"id":"75749761ff4dd3f3","repo":"paperclipai/paperclip","slug":"the-bridge-host-reached-its-reserved-process-body-757497","errorCode":null,"errorMessage":"The bridge host reached its reserved process body byte ceiling. Retry later.","messagePattern":"The bridge host reached its reserved process body byte ceiling\\. Retry later\\.","errorType":"exception","errorClass":"BridgeProcessCapacityError","httpStatus":null,"severity":"error","filePath":"packages/adapter-utils/src/http2-bridge-server.ts","lineNumber":992,"sourceCode":" * chunk joins the retained array, and reserves the concatenated buffer's own\n * byte count before `Buffer.concat` allocates it — the chunk array and the\n * concatenated buffer are two separate live copies, so both reserve. A\n * denied reservation rejects with {@link BridgeProcessCapacityError} and\n * destroys the stream, retaining no further chunk.\n */\nfunction readHttp2StreamBody(\n  stream: http2.ServerHttp2Stream,\n  bounds: Http2BridgeBodyBounds,\n  reservation?: BridgeBodyReservation,\n): Promise<Buffer> {\n  const chunks: Buffer[] = [];\n  let retainedBytes = 0;\n  return readOrDrainHttp2StreamBody(\n    stream,\n    bounds,\n    (chunk, totalBytes) => {\n      if (reservation && !reservation.reserve(chunk.byteLength)) {\n        throw new BridgeProcessCapacityError();\n      }\n      chunks.push(chunk);\n      retainedBytes = totalBytes;\n    },\n    () => {\n      if (reservation && !reservation.reserve(retainedBytes)) {\n        throw new BridgeProcessCapacityError();\n      }\n      return Buffer.concat(chunks);\n    },\n  );\n}\n\n/**\n * Drain and discard one denied stream's request body, under the same size,\n * idle, and lifetime bounds an authenticated request gets, but retaining no\n * chunk and reserving no bytes. `denyRequest` calls this instead of\n * {@link readHttp2StreamBody}, so a stream that never carries a valid bridge","sourceCodeStart":974,"sourceCodeEnd":1010,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/packages/adapter-utils/src/http2-bridge-server.ts#L974-L1010","documentation":"In the HTTP/2 bridge server, per-chunk reservation of a stream body against the shared process body ledger fails: BridgeProcessCapacityError ('reached its reserved process body byte ceiling'). Thrown from the chunk callback of readOrDrainHttp2StreamBody when a single incoming chunk cannot be reserved because the host-wide pool is exhausted by concurrent usage.","triggerScenarios":"An HTTP/2 stream body arrives while the bridge host's reserved process body byte pool is fully consumed by other in-flight requests; reservation.reserve(chunk.byteLength) returns false inside the onChunk callback.","commonSituations":"High concurrency on one bridge host; one slow client holding a large reservation while others arrive; misconfigured (too small) byte ceiling; leaked reservations from prior requests never released.","solutions":["Retry the HTTP/2 request after a brief backoff; capacity frees as in-flight bodies are consumed and released.","Audit reservation release paths (finally blocks) to eliminate leaked capacity from earlier failed reads.","Throttle concurrent bridge streams or add admission control before reading bodies.","Raise the reserved process body byte ceiling to match expected concurrency × body size."],"exampleFix":"// before\nif (reservation && !reservation.reserve(chunk.byteLength)) {\n  throw new BridgeProcessCapacityError();\n}\n// after\nif (reservation && !reservation.reserve(chunk.byteLength)) {\n  stream.respond({ ':status': 503, 'retry-after': '2' });\n  throw new BridgeProcessCapacityError();\n}","handlingStrategy":"retry","validationCode":"// Gate streams before reading: if advertised body exceeds per-stream share, reject early.\nconst cl = Number(headers[\"content-length\"] ?? 0);\nif (cl > maxBodyBytes / activeStreams) stream.respond({ \":status\": 503, \"retry-after\": \"2\" });","typeGuard":"null","tryCatchPattern":"try {\n  return await readOrDrainHttp2StreamBody(stream, bounds, onChunk, onFinalize);\n} catch (err) {\n  if (err instanceof BridgeProcessCapacityError) {\n    stream.respond({ \":status\": 503, \"retry-after\": \"2\" });\n    return null;\n  }\n  throw err;\n}","preventionTips":["Add admission control limiting concurrent in-flight stream bodies.","Release ledger reservations on abort/close of every stream.","Monitor ledger occupancy and scale the ceiling with traffic.","Return 503 + Retry-After to clients so they back off cleanly."],"tags":["http2","capacity","concurrency","bridge"],"backgroundTag":"resource-limit-exceeded","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}