Skip to content

fix(claude): clear Anthropic passthrough deadline after headers - #136

Merged
lidge-jun merged 1 commit into
lidge-jun:mainfrom
MustangRider:fix/anthropic-passthrough-header-deadline
Jul 15, 2026
Merged

fix(claude): clear Anthropic passthrough deadline after headers#136
lidge-jun merged 1 commit into
lidge-jun:mainfrom
MustangRider:fix/anthropic-passthrough-header-deadline

Conversation

@MustangRider

Copy link
Copy Markdown
Contributor

Summary

  • replace the native Anthropic passthrough's non-clearable
    AbortSignal.timeout() with the existing clearableDeadline() helper
  • clear the deadline as soon as upstream response headers arrive
  • keep the response body linked to the client request signal
  • add a regression test whose SSE body outlives connectTimeoutMs

Fixes #135

Problem

connectTimeoutMs is a response-header arrival budget, but the native
Anthropic passthrough kept its timeout signal attached to the entire response
body.

As a result, a valid SSE response could be terminated after the deadline even
when its headers arrived immediately.

Test coverage

The new endpoint regression test uses a local mock Anthropic upstream:

  • response headers and message_start arrive immediately
  • connectTimeoutMs is 200 ms
  • message_stop arrives after 600 ms

Before this change, reading the response body ends at the timeout and the
final event is missing. After this change, the complete SSE body arrives.

Verification

  • focused regression test: pass
  • tests/claude-messages-endpoint.test.ts: 12 passed
  • typecheck: pass
  • privacy scan: pass
  • runtime proxy verification:
    • body completed after 681 ms with a 200 ms header deadline
    • delayed response headers still returned 504 after approximately 200 ms

The full Windows test run also reported three unrelated pre-existing
environment/path failures in codex-v2-gate.test.ts and doctor.test.ts;
the Claude endpoint test file passed in full.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
lidge-jun added a commit that referenced this pull request Jul 15, 2026
…etch path

PR #136 follow-up: extract fetchWithHeaderDeadline with a finally-guaranteed
clear() so a rejected fetch no longer leaks the deadline timer. Injectable
deadline factory + fetch impl give deterministic unit coverage of the
success/reject/timeout paths, plus a 502 reject-path endpoint activation test.
lidge-jun added a commit that referenced this pull request Jul 15, 2026
…ning, PR #137 gui i18n, usage surface filter, routed-agent skill guard)
@lidge-jun
lidge-jun merged commit 5ca0ba7 into lidge-jun:main Jul 15, 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.

Anthropic passthrough header deadline aborts long SSE response bodies

2 participants