mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-07 16:08:02 +08:00
coder/websocket arms a context.AfterFunc that hard-closes the connection when a write context is canceled, and AfterFunc stop does not wait for a callback that already started. An external cancellation (e.g. ingress lease loss) landing inside the disarm window of an already-successful downstream write could therefore kill the TCP connection before the retry close frame (1013) was written, leaving the client with a bare EOF. Mirror the read side: bound downstream writes with the write timeout only, and rely on the explicit Close/CloseNow performed by every relay exit path for teardown. Fixes the flaky TestPassthroughLifecycle_LeaseLossSendsRetryClose.