Repository navigation
Description
Client or integration
Direct HTTP/API client
Area
Proxy and routing
Summary
The upload loop awaits the caller body reader before parsing any response head. Aborting destroys the socket but does not settle a pending bodyReader.read(). A stalled upload can therefore keep the fetch promise pending, including when the peer has already returned a final response.
Reproduction
Static source trace at 7864869c31c41cca9830d93540238f17df8faafb; the following fake-upstream regression is the proposed executable reproduction, not a claimed local test result.
- Use a fake SOCKS peer and a Request body stream that produces one chunk and then leaves its next read pending.
- Abort after the headers/chunk arrive, or have the upstream send a final response without waiting for the upload to finish.
- Assert bounded settlement, request-body cancellation, no further upload writes and no orphaned socket/listeners. Do not use a production endpoint.
Version
Operating system
Source review on macOS 27.0; the transport logic is cross-platform. Runtime reproduction has not been executed in this analysis.
Provider and model
Not provider- or model-specific. Use a local fake upstream and no real credentials.
Logs or error output
No live traffic or runtime logs collected. Evidence is the exact source path below.
Screenshots and supporting files
src/lib/socks5-fetch.ts:559; src/lib/socks5-fetch.ts:573; src/lib/socks5-fetch.ts:589. Existing handshake/response abort support is retained; this is a request-body lifecycle gap, not a claim that cancellation is absent. Related #2894.
Redacted configuration
Use a test-owned loopback upstream and SOCKS tunnel or the pinned direct helper as specified above. No user home, provider credentials or running proxy is needed.
Implementation path
- MODIFY
src/lib/socks5-fetch.ts: observe the final response head concurrently with upload, skipping informational responses. - Race body reads/drain waits with caller abort and early final response. On termination, cancel/release the body reader without allowing a hanging cancel callback to block settlement.
- Preserve the first terminal cause and caller abort reason; do not send a terminating chunk after an early final response. Avoid concurrent consumers of the same socket reader.
- ADD focused
tests/lib/socks5-upload-lifecycle.test.tsregressions.
Acceptance criteria and verification
- Pending body read + caller abort rejects with the original reason and releases resources.
- Early final response resolves and stops upload.
- Socket error/timeout during a stalled body read settles rather than hanging.
- Backpressure, normal POST completion and informational response handling remain correct.
New test files must be registered in scripts/test-layout/layout.json and tests/fixtures/test-layout-expected.json; split tests rather than raise file-size caps. Update structure/transports/inventory.md and any other owner declared by the manifest. Run focused regressions and exact-head hosted CI in the implementation PR; no passing runtime result is claimed here.
Checks
- I searched existing issues and documentation.
- I removed secrets, tokens, account details, request credentials, and personal data.
Activity
lidge-jun commentedon Sep 19, 2026
Resolved on dev by #5127, merge commit
9824aa55bb0ed5fb27ca92ed0851a2fd5529123c.The upload and final response are observed concurrently with one socket reader. Stalled uploads settle on caller cancellation or peer response/failure; normal chunked completion remains covered. Regressions activate cancellation only after the upstream receives body bytes and verify Error/string/null/object reasons, early 413, peer disappearance and ordinary POST. Exact head
cc8eeab585a7ce175cecf73268a325497c26eaf4passed all applicable hosted checks and aggregate ci: https://github.com/lidge-jun/opencodex/actions/runs/35432240251. Linux and macOS logs explicitly show the new cases passing.Independent review findings were resolved, current dev integration was inspected to preserve the prior null-body fix, and merged state plus dev tip were reread before closure. Local tests/typecheck/build/install were NOT RUN. The cumulative dev run remains monitored separately.
lidge-jun commentedon Sep 19, 2026
Final acceptance audit found missing direct activation evidence for two original criteria: informational response handling before the final response, and timeout settlement while an upload body read is stalled. Reopening for focused real-transport regressions and hosted proof, preserving deadlines and existing assertions. Existing implementation/CI evidence remains recorded; no new production failure is asserted. Re-closure will follow the verified regression follow-up landing.
Cover HEAD preservation, interim answers and the SOCKS response timeo…
lidge-jun commentedon Sep 20, 2026
Original acceptance verification is now complete. Follow-up #5225 landed on dev as3f9fe3fa2993126c95a0c64627f4a5d609e0a1a7; ancestry and the reviewed tree are verified. Exact-head run35477114410 passed, and macOS log105988178063 directly shows the informational100/103→continued upload→final200 case and the real timeout callback during a stalled read passing, including resource cleanup. Original #5127 coverage remains intact. No production behavior, deadline or assertion was weakened.