Remove a callback read's pending task right after the callback instead of one `setTimeout(fn, 0)` later
维护者通常 3 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 84/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- angular, firebase, typescript
- 领域
- backend, performance
调研方向
阅读 src/zones.ts,重点查看第 123、153 和 190 行附近的回调包装以及待处理任务的移除。跟踪首次回调和取消订阅的路径,然后检查它们各自如何移除任务,以及回调抛出异常时的行为。完成标准是:任务在首次回调后立即移除,或在取消订阅时移除,不使用定时器,并且符合所述的标记顺序。
由索引模型根据 Issue 内容生成。
描述
Version info
Angular: 22.2
Firebase: 12.19.0
AngularFire: 22.0.0-rc.0, and main
Description
Every callback-taking read that holds a pending task keeps it one setTimeout(fn, 0) delay longer than it needs to:
ɵzoneWrapregisters a pending task when a function wrapped withblockUntilFirsttrue, such asonSnapshot,onAuthStateChangedoronValue, is handed a callback, and removes it withsetTimeout(taskDone, 0)scheduled right before the first callback runs (src/zones.ts:123) and again when the returned unsubscribe is called (:190).- So
ApplicationRef.isStablecan turn true only after that timer callback has run, one macrotask after the first value arrived. The comment next to the wrapping call,// TODO create a microtask to track callback functions(:153), asks for a microtask in its place. - #3833 moved the Observable-returning reads off their timer. The callback reads are the remaining branch.
- Removing the task in a
finallyright after the callback body needs no timer and keeps a throwing callback from leaving its task behind.
How to reproduce these conditions
On a fresh Angular 22.2 app with @angular/fire@next, wrap a callback-taking function with the real ɵzoneWrap, invoke the callback from a setTimeout(fn, 0) outside Angular, and inside that same setTimeout callback, before invoking it, register a second setTimeout(fn, 0) and a queueMicrotask as markers. Observe the moment the wrapper calls the remover function that PendingTasks.add() returned:
- The marker
setTimeoutcallback has already run, in a zone.js app and a zoneless one, in Chrome and Firefox, for the first callback and for unsubscribe. - With the task removed in a
finallyafter the callback body, the remover is called before either marker has run, in every one of those runs. - The real
onSnapshotagainst the Firestore emulator, with the markers registered by a raw SDK listener attached first to the same document, reads the same way: the remover runs after the markersetTimeoutcallback today, and before it with the change.
Expected behavior
A callback read's pending task is removed as soon as its first callback has run, or as soon as it is unsubscribed.
Actual behavior
The task is removed one setTimeout(fn, 0) delay later.
- 主要语言
- TypeScript
- 星标
- 7.8k
- 派生
- 2.2k
- 平均合并
- 2 天 21 小时
- 30 天内合并 PR
- 24
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
angular/angularfire 的其他 Issue
-
Document the 22.0.0-rc.1 changes可能已有人在做 @armando-navarro 于 5 天前认领。 未关闭comp: docs type: chore
难度 3/5 半天 新手友好度 18/100
angular/angularfire#3834 ·
维护者通常 3 天内回复
-
`ɵzoneWrap` ignores a handler passed as an observer object, and holds a wrapped promise forever once its injector is destroyed可能已有人在做 @armando-navarro 于 6 天前认领。 未关闭comp: app-check comp: core comp: firestore comp: remote-config comp: zones type: bug version: current (v17+)
难度 4/5 3-5 天 新手友好度 25/100
angular/angularfire#3828 ·
维护者通常 3 天内回复
-
comp: compat comp: firestore comp: storage type: chore
难度 4/5 3-5 天 新手友好度 48/100
angular/angularfire#3822 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 55/100
angular/angularfire#3800 · 1 个 reaction ·
维护者通常 3 天内回复
-
Use `TransferState` to hand server-rendered Firestore data to the browser, instead of reading every document twice可能重新可做 @armando-navarro 于 66 天前认领,目前没有进行中的 PR。 未关闭comp: firestore comp: ssr priority: P0 (critical) type: feature version: current (v17+)
angular/angularfire#3757 · 已指派 1 人 ·
维护者通常 3 天内回复
查看 angular/angularfire 的全部 Issue
相似的 Issue
-
area: web bug
难度 2/5 1-3 小时 新手友好度 76/100
kinqsradio/orbyn-engineering#227 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
joeldesante/TurfBuilder#258 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
ncecere/open-mcp-portal#85 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 63/100
loathers/garbage-collector#2865 ·
维护者通常 1 天内回复
-
test-reliability
难度 2/5 1-3 小时 新手友好度 78/100
Azure/azure-sdk-for-js#40672 · 1 个 reaction ·
维护者通常 1 天内回复