Repository navigation
test: 开发机代理环境泄漏进「无网络」测试的隔离修复 - #58
Merged
Merged
Conversation
两套 fetch-stub 测试在带代理的开发机上必挂(CI 无代理不暴露): fetchJsonRace 的 viaProxy 路径走 node:http/tls 原生模块直连代理服务器, 完全绕过 globalThis.fetch stub——shell 里的 https_proxy / HTTPS_PROXY / ALL_PROXY 让真网络请求闯进测试,探测结果被真实响应覆盖。 实测(Windows + https_proxy=http://localhost:7897 + zcode-net.json proxyFirst=true): - web-session-watch 3/4 挂,单测耗时 6-8s(真网络往返) - robustness-audit「200 但非 JSON」挂(同根因) - 摘掉代理变量后全部 <50ms 通过 修复(只动测试文件,产品代码零改动): 1. 两文件头部统一摘除 https_proxy/HTTPS_PROXY/http_proxy/HTTP_PROXY/ ALL_PROXY/all_proxy——「全部注入 fetch,无网络」的承诺靠这个兑现 2. seedQoder 补 id:缺 id 时 find(x.id === acc.id) 退化成「找第一个 undefined id 的账号」,多账号共存时永远命中第一个种子,断言到错的记录 3. store 投影测试改按精确 id 寻址(原模糊 find(x.meta?.qoderWebDead) 会被前面测试留下的死标记账号串位)
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.
问题
两套 fetch-stub 测试在带代理的开发机上必挂,CI(无代理)不暴露:
web-session-watch.test.js3/4 挂robustness-audit.test.js「200 但非 JSON」挂单测耗时 6-17 秒(真网络往返),失败信息与测试语义完全对不上(「复活后应清标记」失败实际是复活轮的真网响应盖掉了 stub 的 200)。
根因
fetchJsonRace的 viaProxy 路径走node:http/node:tls原生模块直连代理服务器,完全绕过globalThis.fetchstub。开发机 shell 带代理变量时:effectiveProxy()的来源:zcode-net.json的proxyUrl或HTTPS_PROXY等环境变量——测试的临时CREDITDADDY_HOME只隔离了前者,环境变量这条路没堵。修复(只动测试文件,产品代码零改动)
https_proxy/HTTPS_PROXY/http_proxy/HTTP_PROXY/ALL_PROXY/all_proxy)——「无网络」承诺靠这个兑现seedQoder补id:缺 id 时find(x.id === acc.id)退化成「找第一个 undefined id 的账号」,多账号共存时永远命中第一个种子,断言到错的记录上;产品代码withAccounts的list.find((x) => x.id === a.id)同样受益于精确寻址find(x.meta?.qoderWebDead)会被前面测试留下的死标记账号串位验证