Repository navigation
fix(tui): guest 验证码 SDK 报错不再终止 TUI - #43
Merged
TriDefender merged 1 commit intoSep 6, 2026
Merged
Conversation
现场报告(v4.5.5,多次复现,间隔十几到二十几分钟):
zcode-proxy: tui crashed: ReferenceError: moveBy is not defined
at tE (https://g.alicdn.com/captcha-frontend/FeiLin/1.5.1/feilin008….js:1:169658)
Bun 下 happy-dom 的 VM 隔离不生效,Aliyun/FeiLin 脚本直接运行在宿主 realm,
因此从它们的回调里逃逸的异常会以进程级 uncaughtException 到达,与我们自己的
故障无从区分。serve 模式早已划清这条界线(captcha-happy.ts 记录后继续运行,
单次求解失败由池重试);TUI 的处理器却对一切 exit(1),把一个可恢复故障放大成
了整个代理进程死亡。
新增 runtime/guest-error.ts 按抛出帧的来源判定归属:仅当栈/sourceURL/message
中出现 SDK 的 CDN 主机才算 guest。判据锚定在 URL authority 上并要求分隔符
收尾,所以 `evil-alicdn.com.attacker.net` 与 `?ref=alicdn.com` 都不算证据;
同时跟随 cause 链(带自引用保护)。取证不足一律判为宿主故障——沉默地吞掉真实
崩溃比误杀更糟。
TUI 据此放行 guest 报错并写入日志面板,其余仍照旧 cleanup + exit(1)。
验证:把现场那条栈注入 stock captcha-happy,TUI 存活且面板出现
"ReferenceError: moveBy is not defined (tE (feilin008….js))";真实内部故障
仍然退出。
TriDefender
approved these changes
Sep 6, 2026
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.
背景
v4.5.5 TUI 模式下反复崩溃(实际使用中间隔 2m47s / 14m37s / 27m15s / 29m15s):
追查后确认这不是单点缺陷,而是四个可独立修复的问题叠加。崩溃链条:
tE是个 2 秒心跳,会自我重新武装(feilin008.js:170382tV=setInterval(tE,2e3))happyDOM.close()收不走 → 不朽定时器delete掉moveBy,心跳下次触发即ReferenceErroruncaughtException处理器对一切exit(1)→ 代理进程死亡本 PR 切断第 4 环,与其余三个 PR 互不依赖,可单独合入。
问题
Bun 下 happy-dom 的 VM 隔离不生效,Aliyun/FeiLin 脚本直接运行在宿主 realm。因此从它们回调里逃逸的异常,会以进程级
uncaughtException到达,与我们自己的故障无从区分。serve模式早已划清这条界线 ——captcha-happy.ts记录后继续运行,单次求解失败由池重试。TUI 的处理器却对一切exit(1),把一个可恢复故障放大成了整个代理进程死亡。同一条异常在两种模式下的命运(实测):
serveexitCode=0,打印[captcha-guest-uncaught]后继续服务exitCode=1,进程死亡改动
新增
src/runtime/guest-error.ts,按抛出帧的来源判定归属:仅当栈 /sourceURL/ message 中出现 SDK 的 CDN 主机才算 guest。判据锚定在 URL authority 上并要求分隔符收尾,因此不会被绕过:
https://g.alicdn.com/…/feilin008….jshttps://o.alicdn.com/…/AliyunCaptcha.jshttps://captcha.ap-southeast-1.aliyuncs.com/x.jshttps://evil-alicdn.com.attacker.net/x.jshttps://cdn.example.com/p?ref=alicdn.com同时跟随
cause链(带自引用保护,循环不会死循环)。取证不足一律判为宿主故障 —— 无栈、非 Error 对象、
undefined全部走致命路径。沉默地吞掉真实崩溃比误杀更糟。TUI 据此放行 guest 报错并写入日志面板,其余仍照旧
cleanup()+exit(1)。验证
在 stock
captcha-happy(不含其余三个 PR)上注入现场那条栈:真实内部故障仍然退出:
bun x tsc --noEmit0 错误bun test739 pass / 0 fail(上游基线 732,本 PR 新增 7 条分类器测试)