Skip to content

fix(responses): surface rewrite failures before tee cancellation - #3683

Merged
lidge-jun merged 7 commits into
devfrom
codex/a-01-sse
Sep 5, 2026
Merged

fix(responses): surface rewrite failures before tee cancellation#3683
lidge-jun merged 7 commits into
devfrom
codex/a-01-sse

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Summary

A rewrite failure currently waits for cancellation of a tee branch before reaching the client. When the inspection sibling remains open, that ordering can leave the request hanging. Surface the failure immediately while handling cancellation asynchronously; retain the original real-tee resolve/reject regressions and transport documentation from #3672.

Carries #3672 with the original author and source commit preserved. The numbered roadmap records the separately reviewed A integration layers.

Stack (merge bottom-up):

Layer Source Review focus
0 — foundation #3696 Deterministic Windows shutdown verification
1 — this PR #3672 SSE failure termination
2 — planned #3679 WebSocket outbound proxy selection
3 — planned #3568 Native MESSAGE recovery
4 — planned #3581 Command Code conversation affinity
5 — planned #3671 Effective provider capabilities

Verification

  • Independent plan audit passed; source-parent/current-dev comparison found no drift in the three implementation files.
  • git diff --check passed.
  • No local test suite, typecheck or build executed, per maintainer instruction.
  • Exact head 4b34cbb8d3f308cd2b01e8d87784c65afb50a40f, isolated remote Bun 1.3.14: 23 focused tests passed, 0 failed; typecheck passed.
  • Regression control: restoring only the parent rewriter made both new real-tee cases fail with the expected inspection-wait timeout; candidate source restored afterwards.
  • Independent implementation review: no blocking findings.
  • Full cross-platform CI including Windows was superseded before completion: https://github.com/lidge-jun/opencodex/actions/runs/33978547130 . This PR remains draft until required verification and review finish.

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.

Co-authored-by: Hako 25837994+devswha@users.noreply.github.com

Verification update: the additional manual full-CI run on this pre-repair head was cancelled after existing Windows shutdown-spill fixture defects were identified. Normal PR verification and captured logs are retained. A separate deterministic fixture repair will be inserted beneath the stack; required CI will be rerun on refreshed heads before admin merge. No passing full-Windows claim is made.

Current stack verification: head 75cf985ff724697a01e82e8778265c34a804e34f, base codex/a-00-windows-fixtures. Foundation #3696 is included; all five layer diffs are byte-identical to their independently reviewed pre-foundation diffs, and original contributor commits remain ancestors. Prior focused results above are pre-restack evidence. Current-head full CI: https://github.com/lidge-jun/opencodex/actions/runs/33981578769 . Required completion is pending; admin merge remains bottom-up.

Depends on #3696.

@coderabbitai

coderabbitai Bot commented Sep 5, 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

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 Sep 5, 2026

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@lidge-jun

Copy link
Copy Markdown
Owner Author

리뷰 · 우선순위 72 / 80

이 PR은 SSE rewrite가 실패했을 때 클라이언트에 에러를 보이기 전에 tee 형제 취소가 끝나길 기다리던 순서를 고칩니다. 지금 HEAD 81871b3fasrc/server/sse-payload-rewrite.ts는 catch에서 await reader.cancel(error)를 한 뒤에야 controller.error(error)를 호출합니다. tee의 inspection 쪽 reader가 아직 열려 있으면 cancel Promise가 안 끝나서, rewrite 예산 초과 같은 실패가 클라이언트에 안 가고 요청이 매달릴 수 있습니다. 변경은 그 await를 void reader.cancel(error).catch(() => {{}}로 바꾸고, 실패를 즉시 surface한 뒤 취소는 비동기로 돌리는 한 줄입니다. 원본 #3672 carry이고, A 런타임 스택 1/5(SSE)입니다. 위층 #3686(WS 프록시)이 이 브랜치를 base로 씁니다.

테스트가 핵심입니다. real tee로 inspection을 열어 둔 채 rewrite 실패를 만들고, 1초 안에 response.failed / translation_buffer_limit / [DONE]가 오는지 확인합니다. cancel이 아직 0인 동안 클라이언트가 끝나는지, 나중에 inspection을 풀었을 때 resolve/reject 둘 다 처리하는지도 봅니다. 회귀 대조로 부모 rewriter만 되돌려 보면 inspection-wait 타임아웃이 난다고 본문에 적혀 있습니다. 구현 파일은 사실상 한 곳이고, 계획 문서 덩어리는 A 스택 로드맵이라 리뷰 범위에서 빼도 됩니다. types/config 분할과 무관하고, 2.44.0 dev 라인의 전송 안정성 버그픽스입니다.

A 레인에서 SSE는 모든 responses 번역 경로의 공통 껍질입니다. 여기서 hang이 나면 상류 실패가 클라이언트에 안 보이고, 위층 WS 프록시(#3686) 회귀도 “느린 실패”로 오인하기 쉽습니다. 한 줄 변경에 real-tee 회귀를 붙인 구성이 이 레인의 취지에 맞습니다. 계획 문서 벌크는 실행 로그일 뿐이고, 머지 판단은 구현+테스트+CI에 두면 됩니다.

라인 src/server/sse-payload-rewrite.ts ~252 - HEAD는 여전히 await reader.cancel(error)입니다. 이 PR이 void+catch로 바꿉니다. hang의 직접 원인입니다.

경로 테스트 real-tee resolve/reject - inspection이 열린 동안 실패가 1초 안에 표면에 나와야 합니다. 취소 결과(성공/거부)와 클라이언트 완료를 분리한 점이 좋습니다.

경로 문서 proxy-formats.md - transport 계약을 짧게 보강한 수준입니다. 동작 변경의 부록입니다.

경로 스택 - A 레인 바닥입니다. #3686 이하가 여기 위에 쌓입니다. CI(특히 Windows 포함 full) 통과 전이 ready면 안 됩니다.

경로 원본 #3672 - OPEN 유지. dev 조상 증명 후 landed로 닫으세요.

경로 plan 문서 벌크 - 020_ws 등 상위 레이어 계획이 같이 들어 있지만, 이 PR 리뷰 범위는 SSE 한 줄+테스트입니다. 계획 전체가 머지 블로커는 아닙니다.

메인테이너의 판단이 필요한 지점

  • plan 문서를 이 PR에 같이 넣을지, 구현만 남기고 로드맵은 별 docs PR로 둘지
  • full CI가 끝나기 전에 다음 층(#3686) 리뷰만 진행할지
  • cancel rejection을 void catch로 삼키는 것이 충분한지, 로그/메트릭이 필요한지

너의 추천
구현이 작고 회귀가 강합니다. focused 테스트·typecheck·full CI가 초록이면 머지하고 A 스택을 열어 주세요. plan 문서가 부담이면 구현 커밋만 남겨도 됩니다. 머지 후 #3672를 landed로 닫고 #3686 diff만 이어서 보면 됩니다.

이 댓글은 grok-bot이 작성했습니다

@lidge-jun
lidge-jun changed the base branch from dev to codex/a-00-windows-fixtures September 5, 2026 17:36
@lidge-jun
lidge-jun changed the base branch from codex/a-00-windows-fixtures to dev September 5, 2026 18:12
@lidge-jun
lidge-jun marked this pull request as ready for review September 5, 2026 18:27
@lidge-jun

Copy link
Copy Markdown
Owner Author

Owner-authorized admin merge of #3683, carrying #3672 with original contributor commits and attribution preserved.

Exact head: 75cf985. All functional producers in full cross-platform run https://github.com/lidge-jun/opencodex/actions/runs/33981578769 succeeded, including all Linux/macOS/Windows suite jobs, unsharded macOS control, type/privacy gates and platform smokes. Any remaining queued ci aggregation is evaluated directly by its success/skipped allowlist; no unexecuted tests or failures are bypassed.

Independent implementation/security review passed. Foundation restacking preserved the complete layer diff byte-for-byte and retained original contributor commits. Child retargeting precedes auto-deletion. Final dev inclusion will be checked immediately after merge.

Co-authored-by: Hako 25837994+devswha@users.noreply.github.com

@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner September 5, 2026 18:27
@lidge-jun
lidge-jun merged commit c6d8678 into dev Sep 5, 2026
63 of 65 checks passed
@lidge-jun
lidge-jun deleted the codex/a-01-sse branch September 5, 2026 18:27
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-05T18:29:08.279233Z 75cf985 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants