Repository navigation
fix(ssrf): 受保护请求改由依赖自带的 undici 发出,并透出底层错误码 (#984) - #985
Merged
Merged
Conversation
旧实现把 node_modules 里 undici@6 的 Agent 当 dispatcher 交给运行时内置 fetch。 dispatcher 与 fetch 分属两份 undici 副本,接口不保证兼容:Node 22/24 与内置 undici 同代侥幸能跑,Node 26(内置已 7.x)校验 handler 的 onError 不通过, 在建立连接之前就同步抛 TypeError: fetch failed (cause: InvalidArgumentError: invalid onError method,约 11ms 返回、根本没出网), 表现为「整站搜不到源、代理全 502」,且错误信息只剩 fetch failed。 - ssrf.ts:受作用域保护的请求改用 undici 自己导出的 fetch,与 Agent 同一副本, 运行时内置 undici 怎么换代都影响不到;非受保护路径仍走原 globalThis.fetch, 全局行为不变。 - fetch-utils.ts:normalizeSSRFError 把 cause 的 code + message 提到对外错误里 (并把 code 挂到顶层便于分类),超时/主动中断原样透传,不破坏调用方的 TimeoutError 判定——LibreSpark#969 那类反馈此前一律只能看到 fetch failed。 - 回归用例:钉住「受保护请求的响应不是全局 Response 实例」,跨副本实现在 Node 26 上会直接失败(修复前 3 条红);另补 4 条错误归一化断言。 - ci.yml:Node 22 / 24 / 26 三版本矩阵,fail-fast: false。此前固定在 22, 这类运行时内部漂移没有任何信号。 实测:Node 26 单测 49 通过;2.23.0 独立包 + Node 26.13.1 生产模式 修复前 search 返回空 + failures「fetch failed」、proxy 502,修复后 search 有结果、JSON 代理 200、m3u8 代理 200 且地址重写正常;Node 22 无回归 (typecheck / lint / 607 测试全绿)。
metathrone
pushed a commit
to metathrone/LibreTV
that referenced
this pull request
Nov 20, 2026
fix(ssrf): 受保护请求改由依赖自带的 undici 发出,并透出底层错误码 (LibreSpark#984)
metathrone
pushed a commit
to metathrone/LibreTV
that referenced
this pull request
Nov 20, 2026
上游已合入 PR LibreSpark#985(=本地 4771dcd+b055482 的同一改动,squash 成 eb6cbe0)。 这里把上游的合并点接回来,让 main 同时含 2.23.0 的功能改动与 2.23.1 版本号。
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.
旧实现把 node_modules 里 undici@6 的 Agent 当 dispatcher 交给运行时内置 fetch。 dispatcher 与 fetch 分属两份 undici 副本,接口不保证兼容:Node 22/24 与内置 undici 同代侥幸能跑,Node 26(内置已 7.x)校验 handler 的 onError 不通过, 在建立连接之前就同步抛 TypeError: fetch failed
(cause: InvalidArgumentError: invalid onError method,约 11ms 返回、根本没出网), 表现为「整站搜不到源、代理全 502」,且错误信息只剩 fetch failed。
实测:Node 26 单测 49 通过;2.23.0 独立包 + Node 26.13.1 生产模式 修复前 search 返回空 + failures「fetch failed」、proxy 502,修复后 search 有结果、JSON 代理 200、m3u8 代理 200 且地址重写正常;Node 22 无回归 (typecheck / lint / 607 测试全绿)。