Repository navigation
Conversation
Export the custom 590-599 status code map from the package entry point so consumers don't have to duplicate it. The object is frozen so that consumers cannot change the codes the server itself responds with. Closes #593 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UdrrEDr4ikhaZRb2M7jyM8
The map also holds 504 Gateway Timeout and describes upstream failures in general, so the old name was misleading. Renamed before it becomes public. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UdrrEDr4ikhaZRb2M7jyM8
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UdrrEDr4ikhaZRb2M7jyM8
- Add and export an UpstreamErrorStatusCode type for the code values, and use it for errorCodeToStatusCode and socksErrorMessageToStatusCode. - Drop the redundant `as const` next to Object.freeze and the no-op one on errorCodeToStatusCode. - Register the STATUS_CODES reason phrases by key instead of repeating the numbers. - Document every key, including TIMEOUT (504), in the README. - Note the selective statuses.ts export in docs/agents/architecture.md. - Name the unit tests after what they check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UdrrEDhY1FTbje75nFktTS
- Rename the exported constant to UPSTREAM_ERROR_STATUS_CODE, following the SCREAMING_SNAKE, singular and ValueOf conventions in docs/agents/typescript.md. - Drop TIMEOUT (504) from the exported constant. A target can return its own 504, which the proxy passes through, so clients could not tell the two apart. The timeout code stays internal. - Update the README table, the unit test and the architecture notes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UdrrEDhY1FTbje75nFktTS
Replace the hard-coded 590-599 values in the e2e tests with the exported constant. The unit test keeps the literal values, since it pins the published codes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UdrrEDhY1FTbje75nFktTS
daniil-poletaev
left a comment
There was a problem hiding this comment.
Looks good!
Just 1 thing:
new UpstreamErrorStatusCode type doesn't include 504, but the server still returns 504 when an upstream proxy times out. Is it intended?
|
Yes, leaving 504 out is intentional. The proxy still returns It isn't exported because a target server can send its own
Generated by Claude Code |
Closes #593
What
Exports the custom 590–599 status codes from the package entry point as
UPSTREAM_ERROR_STATUS_CODE, plus theUpstreamErrorStatusCodetype for their values:Why
The codes are already a documented public contract in the README, so consumers end up hard-coding them. Exporting the constant lets them reference the codes by name.
How
badGatewayStatusCodestoUPSTREAM_ERROR_STATUS_CODE, following the constant naming indocs/agents/typescript.md.504timeout code stays internal, because a target can return its own504, which the proxy passes through, so clients could not tell the two apart.Object.freeze, so a consumer can't change the codes the server itself responds with.statuses.tsstay internal.STATUS_CODESreason phrases are now registered by key instead of repeating the numbers.Risks
This only adds to the public API. Once released, renaming the constant or its keys would be a breaking change.
Testing
Type-check, lint, build and unit tests pass. The e2e suite fails the same 55 puppeteer and SOCKS tests with and without this change, in an environment without a browser or SOCKS upstream, and has no new failures.
https://claude.ai/code/session_01UdrrEDhY1FTbje75nFktTS
Generated by Claude Code