Skip to content

fix: bound retained payloads and avoid stream cloning - #56

Open
satvikpadhiyar wants to merge 2 commits into
snipeship:mainfrom
satvikpadhiyar:fix-cap-payload-retention-memory
Open

fix: bound retained payloads and avoid stream cloning#56
satvikpadhiyar wants to merge 2 commits into
snipeship:mainfrom
satvikpadhiyar:fix-cap-payload-retention-memory

Conversation

@satvikpadhiyar

@satvikpadhiyar satvikpadhiyar commented Jun 29, 2026

Copy link
Copy Markdown

Summary

  • Cap persisted request and response bodies before writing request_payloads, while keeping uncapped payloads for linkage and usage extraction.
  • Make CF_MAX_PAYLOAD_BYTES configurable and document it.
  • Skip startup SQLite compact/checkpoint work that can spike memory on large existing databases.
  • Track streaming response chunks inline instead of cloning the upstream Response, avoiding extra Bun stream branches for long Claude/Anthropic streams.

Why

  • Large Claude Code request/response payloads can accumulate in SQLite and make startup maintenance load or rewrite huge data.
  • Response.clone() on streaming upstream responses creates an extra reader branch for analytics. In Bun this can add memory pressure and was observed locally around ECONNRESET/malformed-response failures.

Verification

  • bun test packages/proxy/src/response-handler.test.ts packages/proxy/src/post-processor.worker.test.ts packages/database/src/database-operations.test.ts packages/proxy/src/usage-worker.test.ts
  • bun run typecheck
  • bunx --bun biome check packages/database/src/database-operations.ts packages/proxy/src/post-processor.worker.ts packages/proxy/src/post-processor.worker.test.ts packages/proxy/src/response-handler.ts packages/proxy/src/response-handler.test.ts packages/proxy/src/stream-tee.ts packages/runtime-server/src/startup-maintenance.ts docs/configuration.md

Notes

  • Full repo lint was not used as the gating command because the existing tree has unrelated formatting failures outside this PR scope.

@satvikpadhiyar satvikpadhiyar changed the title fix: cap retained payload bodies fix: bound retained payloads and avoid stream cloning Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant