Skip to content

fix(responses): encode large native Codex HTTP uploads as bytes - #6508

Closed
MaxyMilan wants to merge 1 commit into
lidge-jun:devfrom
MaxyMilan:fix/codex-http-upload-bytes
Closed

MaxyMilan wants to merge 1 commit into
lidge-jun:devfrom
MaxyMilan:fix/codex-http-upload-bytes

Conversation

@MaxyMilan

@MaxyMilan MaxyMilan commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Codex conversations containing many images can repeatedly fail with 429 upstream_reset_replay_refused after falling back from WebSocket to HTTP. In a macOS reproduction with a roughly 25 MB synthetic image request, Bun's string-body upload failed with ECONNRESET before response headers. Sending the serialized JSON as a UTF-8 buffer succeeded; the patched OpenCodex proxy then completed the same size request with response.completed in about five seconds.

Encode native ChatGPT Responses and compact HTTP string bodies of at least 1 MiB at the final physical send. This leaves WebSocket selection, request contents, headers, cancellation, destination selection and replay refusal unchanged. Other endpoints and existing byte/stream bodies keep their current representation.

Add regression coverage for Unicode byte preservation, rebuilt compact destinations, unchanged small/non-native requests, and nested dispatch without extra sends. Update the transport and user documentation.

Verification

  • Before the fix, three new regression cases failed; after it, all 32 focused transport tests passed: bun test tests/responses/responses-fetch-helpers-boundary.test.ts tests/responses/fresh-connection-optout.test.ts tests/responses/provider-egress-fetch.test.ts.
  • bun run typecheck — passed.
  • bun run privacy:scan — passed.
  • bun run structure:check — passed.
  • ./node_modules/bun/bin/bun.exe scripts/test.ts tests/server/server-management-auth.test.ts — 48 passed, 0 failed with the fix applied.
  • cd docs-site && bun install --frozen-lockfile && bun run build — passed; 561 pages and 77,923 internal links checked.
  • Live reproduction on Bun 1.4.0: large string upload failed; byte-buffer upload and the patched local proxy completed successfully. No private conversation contents or credentials are included here.
  • ./node_modules/bun/bin/bun.exe run test:changed on Bun 1.4.0 selected 484 files: 10,905 passed, 34 skipped, 32 failed. The three failures in native-codex-toggle.test.ts, injection-model-suggest-routes.test.ts, and package-tree-integrity.test.ts also reproduce with the unmodified upstream transport. The other 29 were a timeout in server-management-auth.test.ts followed by spend-ledger ownership conflicts; that file passes in isolation with this patch.
  • For comparison, the same 484-file selection on unmodified upstream dev (3bae88cce7400e47a5e69f9fd28749ed25f919f6) produced 10,906 passed, 34 skipped, 26 failed, including different failures. Neither broad run is green; the failure sets differ and are not being represented as fully classified or equivalent.

The full repository suite was not run. This PR remains a draft for maintainer review and CI.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

@coderabbitai

coderabbitai Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (0/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ⬜ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

This PR stays in draft until every box above is ticked.

Hygiene

✅ Deterministic PR hygiene checks passed.

lidge-jun added a commit that referenced this pull request Oct 3, 2026
fix(responses): stabilize large native HTTP uploads (carry #6508)
@lidge-jun

Copy link
Copy Markdown
Owner

Superseded by #6513, now merged into dev as e77bfb4901d405724edc4295caf5d9f0675a672e. The native large-string-to-UTF-8-byte conversion, source regression cases and documentation were carried, with additional threshold, rewritten-destination and abort tests plus precise threshold wording. No implementation part was dropped. Original author/commit provenance and Co-authored-by credit are retained.

The landed head passed required scoped CI: https://github.com/lidge-jun/opencodex/actions/runs/37130246238. Full integrated cross-platform validation and production publication are still upcoming; this closure records delivery to dev, not a release or a new live native-upload acceptance claim. Thank you for the original reproduction and fix.

@lidge-jun lidge-jun closed this Oct 3, 2026
@lidge-jun lidge-jun mentioned this pull request Oct 4, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working superseded

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants