René's URL Explorer Experiment


Title: fix(core): wrap observer-object handlers like functions, and let a wrapped promise settle after teardown by armando-navarro · Pull Request #3829 · angular/angularfire · GitHub

Open Graph Title: fix(core): wrap observer-object handlers like functions, and let a wrapped promise settle after teardown by armando-navarro · Pull Request #3829 · angular/angularfire

X Title: fix(core): wrap observer-object handlers like functions, and let a wrapped promise settle after teardown by armando-navarro · Pull Request #3829 · angular/angularfire

Description: Fixes #3828 ɵzoneWrap now wraps a handler passed as an observer object the way it wraps a handler passed as a function, for the 11 functions whose declared parameters include an observer. Firebase receives a copy of the object whose next, error, complete, onNext, onErr and onComplete members are wrapped and bound to the caller's object. tools/build.ts finds those 11 at build time by reading Firebase's type declarations with the TypeScript compiler API, and passes them a fourth ɵzoneWrap argument, true. Every other wrapped function passes its object arguments through untouched. onConfigUpdate (remote-config) gets blockUntilFirst: false, because wrapping its observer at true would hold the application unstable until a config update a normal load may never produce. The promise branch resolves and rejects directly, dropping the runInInjectionContext and NgZone.run layers that never reached the caller and threw once the injector was destroyed. A handler Firebase calls after its injector is destroyed now runs instead of throwing NG0205, in both forms. Checklist Issue number for this PR: #3828 Docs included?: no. One sentence in docs/zones.md, saying the re-entry holds for a handler passed as an object too, goes in the rc.1 docs PR, #3835. Test units included?: yes. src/zones.spec.ts has fifteen cases, each run under provideZoneChangeDetection() and under provideZonelessChangeDetection(). src/firestore/firestore.spec.ts has one more, against the real setDoc and the emulator. Breaking change?: no In a clean directory, yarn install, yarn test run successfully?: yes, with npm: npm ci, npm run build, npm test (which runs build:jasmine, test:node-esm and test:chrome-headless), plus npm run test:node and npm run lint. Changes Before this change the argument loop in ɵzoneWrap tested typeof _arguments[i] === 'function' and nothing else, so an observer object reached the SDK untouched. The issue lists the eleven affected functions and what each form lost. The first commit: Adds isObserverLike, true for a non-null object with a function under any of the six member names, and zoneWrapObserver, which returns a copy of the object with those members replaced by the same wrapper a function argument gets. The copy keeps the caller's object untouched, so one observer can be reused across calls, and .bind(observer) keeps this for a class instance or an RxJS Subject. Adds onConfigUpdate: { blockUntilFirst: false, logLevel: LogLevel.WARN } to the remote-config block of tools/build.ts. Its handler runs only when a fetched template differs from the active one. Adds the same entry for app-check's onTokenChanged, which #3827 also added on main, so after the merge only the onConfigUpdate entry is new. The second commit: Replaces ret.then((it) => runInInjectionContext(injector, () => run(() => resolve(it))), ...) with ret.then(resolve, reject). The two layers never reached the caller's continuation, and their assertNotDestroyed check is what hung a promise settling after teardown (the issue has the details). The pending task still opens on the call and closes on settlement. The third commit: Narrows the first commit, which treated any object argument with one of those members as an observer. A model class with a complete() method, saved through setDoc with a converter, reached the converter as a plain copy without its prototype, and the call's pending task was never released. Adds exportsTakingAnObserver to tools/build.ts. It type-checks an in-memory file that imports each Firebase entry point, and keeps the exports with a parameter whose type is an object with a function-valued observer member. Those 11 exports are generated as ɵzoneWrap(fn, blockUntilFirst, logLevel, true). ɵzoneWrap looks for an observer object only when that fourth argument is true. Makes zoneWrapFn call the handler directly when injector.destroyed is true. Before, a handler Firebase called after ApplicationRef.destroy() or a TestBed reset threw NG0205, which already happened on main for handlers passed as functions. The merge of main: Brings in #3827, #3831 and #3833. The remote-config override block keeps both #3827's isSupported entry and this PR's onConfigUpdate entry. src/zones.spec.ts, which both sides created, keeps both sets of specs. The generated files come from the merged build. What callers can notice onSnapshot(ref, { next }) and the other object-form calls now hold server rendering until the first value, run their members inside the Angular zone, and can call inject() inside them, exactly like the function form. onConfigUpdate, which never held the application unstable (its only form was never wrapped), does not start to now that its observer is. Every other wrapped function, setDoc included, receives its object arguments exactly as before this PR. A wrapped promise that settles after its injector is destroyed now settles. Nothing else about the promise branch changes: the continuation's zone and the behavior of inject() inside it are the same as before. A handler that runs after its injector is destroyed runs without the Angular zone and the injection context, instead of throwing NG0205. The SDK receives a copy of the observer rather than the caller's object. None of the eleven SDK functions compares the object's identity: each reads or binds its members, or keeps the object it received and removes that same one on unsubscribe. Verification Removing the injector.destroyed check from zoneWrapFn fails the new teardown spec in both modes with NG0205: Injector has already been destroyed. Removing the fourth-argument check from ɵzoneWrap fails five specs: the two data-object cases in both modes, and the Firestore setDoc converter spec. Full karma suite in headless Chrome on the merged branch: 169 of 169 pass. npm run test:node and npm run test:node-esm: 401 specs, 0 failures each. npm run lint passes. With firebase 13.1.0 installed in place of 12.19.0, the build flags the same 11 exports. Measured in Chrome on a zone.js Angular 22.2 app and a zoneless one with the built tarball installed, against the Firestore emulator, through the generated @angular/fire/firestore and @angular/fire/remote-config entry points: the object form matches the function form on pending task, zone and inject() in both apps, and onConfigUpdate registers no task. This was rerun with the build-time flag in place, before the NG0205 change and the merge. Same apps, the promise branch: getDoc registers and releases its task and resolves with the document, a rejecting wrapped call releases its task and the rejection reaches the caller, the caller's continuation sees the same zone and the same inject() failure as before, and a wrapped call made inside a child EnvironmentInjector that is destroyed before the promise settles resolves. Backport Non-breaking. src/zones.ts on 21.1.x is identical to this branch's starting point. A cherry-pick PR against 21.1.x follows at a later date, after a run on an Angular 21 app.

Open Graph Description: Fixes #3828 ɵzoneWrap now wraps a handler passed as an observer object the way it wraps a handler passed as a function, for the 11 functions whose declared parameters include an observer. Firebase...

X Description: Fixes #3828 ɵzoneWrap now wraps a handler passed as an observer object the way it wraps a handler passed as a function, for the 11 functions whose declared parameters include an observer. Firebase...

Opengraph URL: https://github.com/angular/angularfire/pull/3829

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.112.4

react-profiling0
react-import-mapreact,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-controllerpull_requests
route-actionfiles
fetch-noncev2:0e421624-2144-0bb5-b2c1-866ceef18ffc
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9964:274D49:234E069:2EA275F:6B03608A
html-safe-nonceaf356ba3b9e183e1d925c9d0df8cf6998a91afb9c2cff0c103aab6f19504634b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTY0OjI3NEQ0OToyMzRFMDY5OjJFQTI3NUY6NkIwMzYwOEEiLCJ2aXNpdG9yX2lkIjoiNTczMDU1NTQyNjM3OTA5NjIwMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac3225352118d40487d1e790c27cd076ddf1822697997df751d4991ed083c52126
hovercard-subject-tagpull_request:5086764491
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/angular/angularfire/pull/3829/files
twitter:imagehttps://avatars.githubusercontent.com/u/13904589?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/13904589?s=400&v=4
og:image:altFixes #3828 ɵzoneWrap now wraps a handler passed as an observer object the way it wraps a handler passed as a function, for the 11 functions whose declared parameters include an observer. Firebase...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/angular/angularfire git https://github.com/angular/angularfire.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id49453413
octolytics-dimension-repository_nwoangular/angularfire
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id49453413
octolytics-dimension-repository_network_root_nwoangular/angularfire
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/angular/angularfire/pull/3829/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangularfire%2Fpull%2F3829%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangularfire%2Fpull%2F3829%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=angular%2Fangularfire
Reloadhttps://github.com/angular/angularfire/pull/3829/files
Reloadhttps://github.com/angular/angularfire/pull/3829/files
Reloadhttps://github.com/angular/angularfire/pull/3829/files
angularhttps://github.com/angular
angularfirehttps://github.com/angular/angularfire
Codehttps://github.com/angular/angularfire
Issues162 (162)https://github.com/angular/angularfire/issues
Pull requests5 (5)https://github.com/angular/angularfire/pulls
Discussionshttps://github.com/angular/angularfire/discussions
Actionshttps://github.com/angular/angularfire/actions
Projectshttps://github.com/angular/angularfire/projects
Security and qualityhttps://github.com/angular/angularfire/security
Insightshttps://github.com/angular/angularfire/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fangular%2Fangularfire%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fangular%2Fangularfire%2Fissues%2Fnew%2Fchoose
armando-navarrohttps://github.com/armando-navarro
angular:mainhttps://github.com/angular/angularfire/tree/main
armando-navarro:a52-observer-handlershttps://github.com/armando-navarro/angularfire/tree/a52-observer-handlers
Conversation 1 https://github.com/angular/angularfire/pull/3829
Commits 4 https://github.com/angular/angularfire/pull/3829/commits
Checks 25 https://github.com/angular/angularfire/pull/3829/checks
Files changed https://github.com/angular/angularfire/pull/3829/files
Please reload this pagehttps://github.com/angular/angularfire/pull/3829/files
fix(core): wrap observer-object handlers like functions, and let a wrapped promise settle after teardown https://github.com/angular/angularfire/pull/3829/files#top
Show all changes 4 commits https://github.com/angular/angularfire/pull/3829/files
6456f32 fix(core): wrap a handler passed as an observer object like a function armando-navarro Oct 30, 2026 https://github.com/angular/angularfire/pull/3829/commits/6456f327113bca163693ca10151e50ae6df3f5a3
0a0bd64 fix(core): let a wrapped promise settle after its injector is destroyed armando-navarro Oct 30, 2026 https://github.com/angular/angularfire/pull/3829/commits/0a0bd6419b5d6eb4b5be63d93926771f7e6a09ba
e16825a fix(core): wrap observer objects only for functions that take one armando-navarro Nov 5, 2026 https://github.com/angular/angularfire/pull/3829/commits/e16825a5071b7ae948d2a9208ee666b2ecd35f10
731b063 Merge remote-tracking branch 'origin/main' into a52-observer-handlers armando-navarro Nov 5, 2026 https://github.com/angular/angularfire/pull/3829/commits/731b063f5bc8f9697278d975f697c860c67f5175
Clear filters https://github.com/angular/angularfire/pull/3829/files
Please reload this pagehttps://github.com/angular/angularfire/pull/3829/files
Please reload this pagehttps://github.com/angular/angularfire/pull/3829/files
firebase.ts https://github.com/angular/angularfire/pull/3829/files#diff-23ad16ca1034818479ab40071c075776c42313d81258adcaf41209b072b9ea43
firebase.ts https://github.com/angular/angularfire/pull/3829/files#diff-09e5ddf9d5e6c379fb4400eb50ac5aef5ed462e68d0c470058df0e7a5ffe3576
firebase.ts https://github.com/angular/angularfire/pull/3829/files#diff-fb1959f9f9db5abf3e53a08fcda00b027e2faf4b8d3d727f38f33578b4113366
firebase.ts https://github.com/angular/angularfire/pull/3829/files#diff-ff611b3530f2510e5113f69088aa15a7bfab31d8e2c95347df01c893d10ac49d
firestore.spec.ts https://github.com/angular/angularfire/pull/3829/files#diff-7cb906fc1ab2793f2d333cf178cd98951335a03279e05d3a85254f4bc1245a46
firebase.ts https://github.com/angular/angularfire/pull/3829/files#diff-ed44ffc919aa0ffe0b2b7632ad958796050e38594c7308b7a9c346d4a83865b9
firebase.ts https://github.com/angular/angularfire/pull/3829/files#diff-5d81c7b30de5ba9c32c3aafd29cfe054d586ec1b065bb2bd72ca897b44c26938
zones.spec.ts https://github.com/angular/angularfire/pull/3829/files#diff-a4d464c99ddd4dba3556da9e413e461a987499810098e655417216b292c761f3
zones.ts https://github.com/angular/angularfire/pull/3829/files#diff-773e71ddabd544410ec64c113754c7f30c2d78b5ce055c1e20d42b8d4a47a640
build.ts https://github.com/angular/angularfire/pull/3829/files#diff-1a7c808f53c100a839513de5b7bffe4aec260620e6f444071f92a143816de975
src/app-check/firebase.tshttps://github.com/angular/angularfire/pull/3829/files#diff-23ad16ca1034818479ab40071c075776c42313d81258adcaf41209b072b9ea43
View file https://github.com/armando-navarro/angularfire/blob/731b063f5bc8f9697278d975f697c860c67f5175/src/app-check/firebase.ts
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/angular/angularfire/pull/3829/files
src/auth/firebase.tshttps://github.com/angular/angularfire/pull/3829/files#diff-09e5ddf9d5e6c379fb4400eb50ac5aef5ed462e68d0c470058df0e7a5ffe3576
View file https://github.com/armando-navarro/angularfire/blob/731b063f5bc8f9697278d975f697c860c67f5175/src/auth/firebase.ts
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/angular/angularfire/pull/3829/files
src/data-connect/firebase.tshttps://github.com/angular/angularfire/pull/3829/files#diff-fb1959f9f9db5abf3e53a08fcda00b027e2faf4b8d3d727f38f33578b4113366
View file https://github.com/armando-navarro/angularfire/blob/731b063f5bc8f9697278d975f697c860c67f5175/src/data-connect/firebase.ts
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/angular/angularfire/pull/3829/files
src/firestore/firebase.tshttps://github.com/angular/angularfire/pull/3829/files#diff-ff611b3530f2510e5113f69088aa15a7bfab31d8e2c95347df01c893d10ac49d
View file https://github.com/armando-navarro/angularfire/blob/731b063f5bc8f9697278d975f697c860c67f5175/src/firestore/firebase.ts
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/angular/angularfire/pull/3829/files
src/firestore/firestore.spec.tshttps://github.com/angular/angularfire/pull/3829/files#diff-7cb906fc1ab2793f2d333cf178cd98951335a03279e05d3a85254f4bc1245a46
View file https://github.com/armando-navarro/angularfire/blob/731b063f5bc8f9697278d975f697c860c67f5175/src/firestore/firestore.spec.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/angular/angularfire/pull/3829/{{ revealButtonHref }}
https://github.com/angular/angularfire/pull/3829/files#diff-7cb906fc1ab2793f2d333cf178cd98951335a03279e05d3a85254f4bc1245a46
https://github.com/angular/angularfire/pull/3829/files#diff-7cb906fc1ab2793f2d333cf178cd98951335a03279e05d3a85254f4bc1245a46
src/messaging/firebase.tshttps://github.com/angular/angularfire/pull/3829/files#diff-ed44ffc919aa0ffe0b2b7632ad958796050e38594c7308b7a9c346d4a83865b9
View file https://github.com/armando-navarro/angularfire/blob/731b063f5bc8f9697278d975f697c860c67f5175/src/messaging/firebase.ts
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/angular/angularfire/pull/3829/files
src/remote-config/firebase.tshttps://github.com/angular/angularfire/pull/3829/files#diff-5d81c7b30de5ba9c32c3aafd29cfe054d586ec1b065bb2bd72ca897b44c26938
View file https://github.com/armando-navarro/angularfire/blob/731b063f5bc8f9697278d975f697c860c67f5175/src/remote-config/firebase.ts
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/angular/angularfire/pull/3829/files
Please reload this pagehttps://github.com/angular/angularfire/pull/3829/files
Please reload this pagehttps://github.com/angular/angularfire/pull/3829/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlno-cache

Viewport: width=device-width


URLs of crawlers that visited me.