Remove a callback read's pending task right after the callback instead of one `setTimeout(fn, 0)` later
Maintainer antworten meist innerhalb von 3 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 84/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- angular, firebase, typescript
- Bereich
- backend, performance
Rechercherichtung
Lies src/zones.ts, insbesondere das Umhüllen des Callbacks und das Entfernen ausstehender Tasks um die Zeilen 123, 153 und 190. Verfolge die Pfade für den ersten Callback und das Abmelden. Prüfe anschließend, wie jeder Pfad den Task entfernt und wie sich der Callback verhält, wenn er einen Fehler auslöst. Fertig ist es, wenn der Task unmittelbar nach dem ersten Callback oder beim Abmelden ohne Timer entfernt wird und die beschriebene Reihenfolge der Marker eingehalten wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 7.8k
- Forks
- 2.2k
- Ø Merge
- 2 T. 21 Std.
- Gemergte PRs (30 T.)
- 24
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus angular/angularfire
-
Document the 22.0.0-rc.1 changesEvtl. vergeben @armando-navarro hat das vor 5 Tagen übernommen. Offencomp: docs type: chore
Schwierigkeit 3/5 Ein halber Tag Anfängerfreundlichkeit 18/100
angular/angularfire#3834 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
`ɵzoneWrap` ignores a handler passed as an observer object, and holds a wrapped promise forever once its injector is destroyedEvtl. vergeben @armando-navarro hat das vor 6 Tagen übernommen. Offencomp: app-check comp: core comp: firestore comp: remote-config comp: zones type: bug version: current (v17+)
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
angular/angularfire#3828 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
comp: compat comp: firestore comp: storage type: chore
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
angular/angularfire#3822 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 55/100
angular/angularfire#3800 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Use `TransferState` to hand server-rendered Firestore data to the browser, instead of reading every document twiceEvtl. wieder frei @armando-navarro hat das vor 65 Tagen übernommen, und es ist kein Pull Request offen. Offencomp: firestore comp: ssr priority: P0 (critical) type: feature version: current (v17+)
angular/angularfire#3757 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 3 Tagen
Alle Issues in angular/angularfire
Ähnliche Issues
-
cloudflare-cache-binding: `unstorage://` keys are rejected by the Cache API, cache never storesOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
Maintainer antworten meist innerhalb von 2 Tagen
-
desktop: pasted image breaks and send fails with "Failed to fetch" after the clipboard temp file is deletedEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offenreproduced
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
anomalyco/opencode#62052 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
strapi/design-system#2084 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag