fix(chat): don't penalize accounts or fail over on client disconnect (stream replay / re-login / non-stream)#225
Merged
Conversation
…_CONNECT paths
A client disconnect mid-attempt could penalize the account, fail over to fresh
accounts (burning quota to a dead socket), and write to a closed stream. Extend
the existing abort handling to the same-token replay, re-login retry, and
non-stream paths.
- src/handlers/chat.js: add isAbortError(err) helper; return {kind:'abort'} (no
penalty) from the stream attempt, transient-replay, and re-login-retry catches;
break the failover loop on abort; guard [DONE] against a closed socket; 499
Client Closed Request on the non-stream path
- test/devin-connect-stream-lifecycle.test.js: +1 — aborts cleanly during a
same-token transient replay when the client disconnects
dwgx
added a commit
that referenced
this pull request
Jul 25, 2026
Owner
|
已合并,谢谢 🙏 覆盖面做得很完整:流式的首次尝试 / transient replay / re-login retry 三条 catch,加非流式主路径与 re-login retry,一条不落。两个防御细节尤其到位 —— replay 启动前重查 对多用户 / 网关前置的部署这是实打实的配额止血 —— 之前每个断连都在罚 error budget + 跨账号 failover,等于用户按一次 Ctrl-C 就烧掉好几个账号的健康度。 合并时与 #226 在 已加入致谢名单,评级 A+。 |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
中文 TL;DR
客户端中途断开时,原来可能给账号记错误、继续 failover(把配额打到已断的 socket)、
往关闭的流里写数据。本 PR 把已有的 abort 处理扩展到 same-token replay / re-login /
非流式路径:不惩罚账号、不 failover、不写死 socket,非流式返回 499。
Summary
Hardening. Extends the existing "client disconnect stops account-hopping" behavior
to the paths it didn't yet cover. Complements #221 (both reduce needless upstream
load on the DEVIN_CONNECT path).
Fix
isAbortError(err)(name / code / message) unifies abort detection.{ kind: 'abort' },finalize with an AbortError (no error-budget penalty), break the failover loop.
[DONE]guarded by!signal.aborted && !res.writableEnded(no write to a dead socket).abortresult →499client_disconnect.Test plan
test/devin-connect-stream-lifecycle.test.js+1: same-token replay + disconnect →replays once, no account hop, no
[DONE], no error frame to the gone clientnpm test→ 2762 pass / 0 failBranch is on current
master(v3.5.0), applies cleanly.