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 於 5 天前認領。 未關閉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 於 65 天前認領,目前沒有進行中的 PR。 未關閉comp: firestore comp: ssr priority: P0 (critical) type: feature version: current (v17+)
angular/angularfire#3757 · 已指派 1 人 ·
維護者通常 3 天內回覆
查看 angular/angularfire 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 66/100
維護者通常 2 天內回覆
-
reproduced
難度 2/5 1-3 小時 新手友好度 74/100
anomalyco/opencode#62052 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
strapi/design-system#2084 ·
維護者通常 3 天內回覆
-
check:passed streams:remove
難度 1/5 1 小時以內 新手友好度 67/100
維護者通常 1 天內回覆
-
OAuth documentation for GET /api/v2/users/me/ appears inconsistent with required global read scope未關閉
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆