Repository navigation
fix(query-core): avoid repeated event listener setup without cleanup - #12302
blueDaydreaming725 wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: c321cfb The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
🎯 Changes
问题: FocusManager/OnlineManager 用
#cleanup是否存在来判断 setup 是否已安装,但当 setup 返回undefined(无需清理)时会被误判为“未安装”,导致每新增订阅者都重复执行 setup,造成多次注册监听器;在 FocusManager 中,一次外部事件会触发多次通知。修复: 将
this.#cleanup = setup(...) ?? noop,用现有空函数兜底代替 undefined,使“已安装但无需清理”和“已安装且有清理逻辑”都能被正确标记,从而避免重复安装。验证: 新增测试确认修复后 setup 只执行一次、焦点事件只通知一次,且全部退订后仍能正常重新初始化。query-core 共 1611 个测试通过,包含 3 个新增测试。
本地检查:
pnpm run test:pr --parallel=1 --base=origin/main成功,337 个任务通过(32 个复用 Nx 缓存)。Preact 示例的类型检查先在无dist的状态下执行,再由完整流程复用;该示例当前会把已有的dist压缩 JS 纳入类型检查,此 PR 未修改该配置。✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Summary by CodeRabbit