Title: feat(zones)!: remove callback pending tasks right after the callback by armando-navarro · Pull Request #3837 · angular/angularfire · GitHub
Open Graph Title: feat(zones)!: remove callback pending tasks right after the callback by armando-navarro · Pull Request #3837 · angular/angularfire
X Title: feat(zones)!: remove callback pending tasks right after the callback by armando-navarro · Pull Request #3837 · angular/angularfire
Description: Checklist Issue number for this PR: #3836 Docs included?: no, the upgrade-guide entry lands on the rc.1 docs PR #3835. Test units included?: yes Breaking change?: yes In a clean directory, yarn install, yarn test run successfully? yes, as npm ci and npm test Description Removes the pending task a callback-taking wrapper registers in a finally right after the callback body, and right after the unsubscribe call, instead of through setTimeout(taskDone, 0) in src/zones.ts. Deletes the 2021 TODO next to the wrapping call that asked for this. The finally runs whether the callback returns or throws, so a throwing callback does not leave its task behind, which the timer also guaranteed. This is the same way Angular's own pendingUntilEvent works: it forwards the value and then removes its task synchronously. Nothing else in the wrapper changes: the task is still registered at call time, the callback still runs inside the Angular zone and the injection context, and the Observable and Promise branches are untouched. What this grants, measured on Angular 22.2 zone.js and zoneless apps, before and after: The task is gone before any setTimeout(fn, 0) callback registered at delivery, in every run: a synthetic callback in Chrome and Firefox, the unsubscribe path, and the real onSnapshot against the Firestore emulator. With Realtime Database on cached data, where the SDK invokes the callback inside the registering call, the task is removed inside that call. A zone.js server render reports stable about a millisecond sooner after a single callback read's first value. In a zoneless render the difference is within noise: the callback's own signal write already schedules Angular's tick, which bounds stability either way. In a zone.js app, a callback delivered inside the Angular zone no longer causes a third change-detection pass. What does not change: The DOM updates on delivery, and the number of change-detection passes for a callback delivered from outside Angular. No task is left behind in the four callback cases probed for #3827 against the emulators. When whenStable() resolves under fake timers. Angular's change-detection tick is itself a timer, so a test that advances fake timers before awaiting whenStable() still needs the advance, before and after. What upgrading apps may notice: whenStable() and server rendering follow a callback read's first value one setTimeout(fn, 0) delay sooner. A test that inspects pending tasks directly sees the wrapper's task gone as soon as the callback has run, without a timer advance. Verification: Four new specs in src/zones.spec.ts, each observing the remover function PendingTasks.add() returns. All four fail on main and pass here: the task is removed after the callback body and before any microtask the body queued, before a setTimeout(fn, 0) callback registered just before delivery the same when the SDK invokes the callback inside the registering call the same on unsubscribe a throwing callback does not leave its task behind npm run lint, npm run test:node, npm run test:chrome-headless and npm run test:firefox-headless pass on the branch.
Open Graph Description: Checklist Issue number for this PR: #3836 Docs included?: no, the upgrade-guide entry lands on the rc.1 docs PR #3835. Test units included?: yes Breaking change?: yes In a clean directory, yarn in...
X Description: Checklist Issue number for this PR: #3836 Docs included?: no, the upgrade-guide entry lands on the rc.1 docs PR #3835. Test units included?: yes Breaking change?: yes In a clean directory, yarn in...
Opengraph URL: https://github.com/angular/angularfire/pull/3837
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:6fa44d04-151f-049b-61a8-4a4a6d44b8dd |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E3A6:3C1C49:2581EF5:314CB98:6B0362EC |
| html-safe-nonce | de8ae6df1763ff7ac988d68598d13af055550dfb3d1eec1cbcc8d067e2bc4d92 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFM0E2OjNDMUM0OToyNTgxRUY1OjMxNENCOTg6NkIwMzYyRUMiLCJ2aXNpdG9yX2lkIjoiMTc3ODQ4ODU5NDQ2NDM2NTg4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2d8df4c5216eb58ab046204e5ed37909dd28a64a09242b0ee5e9633d63633271 |
| hovercard-subject-tag | pull_request:5165317365 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/angular/angularfire/pull/3837/files |
| twitter:image | https://avatars.githubusercontent.com/u/13904589?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/13904589?s=400&v=4 |
| og:image:alt | Checklist Issue number for this PR: #3836 Docs included?: no, the upgrade-guide entry lands on the rc.1 docs PR #3835. Test units included?: yes Breaking change?: yes In a clean directory, yarn in... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/angular/angularfire git https://github.com/angular/angularfire.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 49453413 |
| octolytics-dimension-repository_nwo | angular/angularfire |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49453413 |
| octolytics-dimension-repository_network_root_nwo | angular/angularfire |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width