Repository navigation
Conversation
宿主机端口扫描器会对本地监听端口发 GET /,原来 handler 里的 expect(req.url) 因此抛出,被 vitest 记为 unhandled rejection。 改为非 form-v1 路径一律回 404,并在测试末尾断言没有多余的 POST。 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
swtxbling
requested review from
47seek,
LucasIcarus,
deepcoldy,
xiaoxueSunn and
xiongz-c
as code owners
November 5, 2026 17:51
This was referenced Nov 5, 2026
Owner
|
感谢这个 PR!它的全部改动已随 #2882 合入 master(落地提交 958e9c5):#2882 基于本分支,包含本 PR 的 form 假服务器 404 守卫与多余 POST 断言,并在此基础上覆盖了其余 11 个假服务器,因此本 PR 的有效内容已全部在 master 上(行为等价,且对同一测试文件在 Node 与 Bun 两套测试运行器上均有通过的用例)。 其中 form 假服务器的「多余 POST」记账条件在 #2882 里做了一处收窄(只记录 /api/ 命名空间内的 POST),原因和验证见 #2882 的评审记录:扫描器对随机路径的探测不应被当成 CLI 发错请求。 因此先关闭本 PR。如果认为还有未被覆盖的部分,欢迎随时 reopen 或在 #2882 下留言。 |
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.
改了什么
test/ask-cli.test.ts里两个 fake server(form 结果回执、老接收方)原来在 handler 里expect(req.url).toBe('/api/asks/form-v1')。宿主机的端口扫描器会对本地监听端口发GET /,expect 在 async handler 里抛出,被 vitest 记成 unhandled rejection,导致整次运行退出码随机变红而断言本身都通过。现在非
/api/asks/form-v1的请求直接回 404;非 GET 探针的 POST 会记入strayPosts,测试末尾断言为空,所以 CLI 发错路径仍会被发现。Closes #2722
影响面
只改测试夹具,无 src、helper、CLI 行为变化。
验证
fetch('/'),vitest run --project unit test/ask-cli.test.ts -t form稳定出现Unhandled Rejection: expected '/' to be '/api/asks/form-v1'。npx tsc --noEmit -p tsconfig.json无报错。审查
独立审查 1 轮。指出 404 会让「发往其他路径的 POST」不再被发现,已采纳(加
strayPosts断言)。另提到本文件其余 9 处strict: true读 body 遇到「非空非 JSON」探针仍会抛,当前扫描器只发空 body,本 PR 不扩范围。🤖 Generated with Claude Code