Skip to content

fix: 修复GM xhr不正确处理异常 onloadend 的问题#1412

Merged
CodFrm merged 3 commits intomainfrom
fix/GMxhr/20260507
May 10, 2026
Merged

fix: 修复GM xhr不正确处理异常 onloadend 的问题#1412
CodFrm merged 3 commits intomainfrom
fix/GMxhr/20260507

Conversation

@cyfung1031
Copy link
Copy Markdown
Collaborator

Checklist / 检查清单

  • Fixes mentioned issues / 修复已提及的问题
  • Code reviewed by human / 代码通过人工检查
  • Changes tested / 已完成测试

Description / 描述

  • 修复GM xhr不正确处理异常 onloadend 的问题 (即 abort, timeout, fetch error 等行为)
  • 加入新单元测试项目

Screenshots / 截图

@cyfung1031 cyfung1031 added bug Something isn't working P0 🚑 需要紧急处理的内容 labels May 6, 2026
Comment thread example/tests/gm_xhr_test.js Outdated
Comment on lines +1007 to +1013
// const nwError2 = await runCase(
// {
// url: `https://nonexistent-domain-abcxyz.reject/abc.html`, // disallowed domain
// },
// { abortAfterMs: 500 }
// );
// assertDeepEq(nwError2.events, ["onerror", "onloadend"], "abort fires onerror then onloadend");
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CodFrm 这个跟 权限验证 的设计有关。我不知道你会怎么改(上次改了后你又改回来之类。。不想搞)。这个PR我先不处理。 你可以先合并日后再处理

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我先做了个简单改动处理了
你再看看吧

@CodFrm 修正 权限错误的 onloadend 丢失问题 fd551c6

Copy link
Copy Markdown
Member

@CodFrm CodFrm May 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有和权限验证有关系吧,是因为出现error提前refCleanup了导致连接断掉,没有再发onloadend了?看起来没什么问题

我改的话,可能会更看重 可读性、高内聚、低耦合 一些

Copy link
Copy Markdown
Collaborator Author

@cyfung1031 cyfung1031 May 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有关系的。 verify 里不是跑 xhr 那块事件流程
( xhr 事件流程在‎ src/app/service/content/gm_api/gm_xhr.ts 跑 - 你说得对,我找了很久才找到 「出现error提前refCleanup了导致连接断掉」;
verify 的reject 在 src/app/service/service_worker/gm_api/gm_api.ts 跑 )

但在TM,即使是权限问题,它最后还会有 loadend
在SC就 throw Error 后没了

( 另外,之前 verify 报错后没有 disconnect ... )


我改的话,可能会更看重 可读性、高内聚、低耦合 一些

不过我都修改好了。至少能跑
写法接不接受就看你了

@CodFrm CodFrm merged commit ea5a1a4 into main May 10, 2026
4 checks passed
@CodFrm CodFrm deleted the fix/GMxhr/20260507 branch May 10, 2026 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working P0 🚑 需要紧急处理的内容

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants