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-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:0e421624-2144-0bb5-b2c1-866ceef18ffc |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9964:274D49:234E069:2EA275F:6B03608A |
| html-safe-nonce | af356ba3b9e183e1d925c9d0df8cf6998a91afb9c2cff0c103aab6f19504634b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTY0OjI3NEQ0OToyMzRFMDY5OjJFQTI3NUY6NkIwMzYwOEEiLCJ2aXNpdG9yX2lkIjoiNTczMDU1NTQyNjM3OTA5NjIwMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3225352118d40487d1e790c27cd076ddf1822697997df751d4991ed083c52126 |
| hovercard-subject-tag | pull_request:5086764491 |
| 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 | ///pull_requests/show/files |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/angular/angularfire/pull/3829/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 | 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... |
| 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:
| Skip to content | https://github.com/angular/angularfire/pull/3829/files#start-of-content |
| https://github.com/ |
| Sign in | https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangularfire%2Fpull%2F3829%2Ffiles |
| GitHubRepository hosting, code review, and collaboration | https://github.com/platform |
| CopilotAI coding agent for tasks, projects, and automated work | https://github.com/features/copilot |
| ActionsCI/CD and automation | https://github.com/features/actions |
| Code QualityQuality analysis, fixes, and enforcement | https://github.com/features/code-quality |
| CodespacesCloud development environments | https://github.com/features/codespaces |
| Code SecurityVulnerability detection and remediation | https://github.com/security/advanced-security/code-security |
| Secret ProtectionSecret scanning and leak prevention | https://github.com/security/advanced-security/secret-protection |
| All Features | https://github.com/features |
| Documentation | https://docs.github.com/en |
| Training | https://learn.github.com/skills |
| Certifications | https://learn.github.com/credentials |
| Build with Copilot | https://github.com/features/ai |
| Customize Copilot | https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview |
| Integrations | https://github.com/marketplace |
| Trending repos | https://github.com/trending |
| GitHub Sponsors | https://github.com/open-source/sponsors |
| Developer articles | https://github.com/resources/articles |
| ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place. | https://github.blog/changelog/ |
| Enterprises | https://github.com/enterprise |
| Team | https://github.com/team |
| Startups | https://github.com/enterprise/startups |
| Nonprofits | https://github.com/solutions/industry/nonprofits |
| Healthcare | https://github.com/solutions/industry/healthcare |
| Financial services | https://github.com/solutions/industry/financial-services |
| Manufacturing | https://github.com/solutions/industry/manufacturing |
| Government | https://github.com/solutions/industry/government |
| See all industries | https://github.com/solutions/industry |
| Why GitHub | https://github.com/why-github |
| Customer Stories | https://github.com/customer-stories |
| Business insights | https://github.com/solutions/executive-insights |
| Trust Center | https://github.com/trust-center |
| GitHub Advanced SecurityEnterprise-grade code security | https://github.com/security/advanced-security |
| Copilot for businessEnterprise-grade AI features | https://github.com/features/copilot/copilot-business |
| Premium SupportEnterprise-grade 24/7 support | https://github.com/enterprise/premium-support |
| Documentation | https://docs.github.com/en |
| Resource center | https://github.com/resources |
| Blog | https://github.blog/ |
| Events & webinars | https://github.com/resources/events |
| Community Forum | https://github.com/orgs/community/discussions |
| Customer Stories | https://github.com/customer-stories |
| Integrations | https://github.com/marketplace |
| Customer support | https://help.github.com/ |
| Training | https://learn.github.com/skills |
| GitHub Status | https://www.githubstatus.com/ |
| About | https://github.com/about |
| Partners | https://github.com/partners |
| Changelog | https://github.blog/changelog/ |
| GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub. | https://githubuniverse.com/ |
| Pricing | https://github.com/pricing |
| Sign in | https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangularfire%2Fpull%2F3829%2Ffiles |
| Sign up | https://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 |
| Reload | https://github.com/angular/angularfire/pull/3829/files |
| Reload | https://github.com/angular/angularfire/pull/3829/files |
| Reload | https://github.com/angular/angularfire/pull/3829/files |
| angular | https://github.com/angular |
| angularfire | https://github.com/angular/angularfire |
| Code | https://github.com/angular/angularfire |
| Issues162 (162) | https://github.com/angular/angularfire/issues |
| Pull requests5 (5) | https://github.com/angular/angularfire/pulls |
| Discussions | https://github.com/angular/angularfire/discussions |
| Actions | https://github.com/angular/angularfire/actions |
| Projects | https://github.com/angular/angularfire/projects |
| Security and quality | https://github.com/angular/angularfire/security |
| Insights | https://github.com/angular/angularfire/insights |
| Sign up for GitHub
| https://github.com/signup?return_to=%2Fangular%2Fangularfire%2Fissues%2Fnew%2Fchoose |
| terms of service | https://docs.github.com/terms |
| privacy statement | https://docs.github.com/privacy |
| Sign in | https://github.com/login?return_to=%2Fangular%2Fangularfire%2Fissues%2Fnew%2Fchoose |
| armando-navarro | https://github.com/armando-navarro |
| angular:main | https://github.com/angular/angularfire/tree/main |
| armando-navarro:a52-observer-handlers | https://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 page | https://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 page | https://github.com/angular/angularfire/pull/3829/files |
| Please reload this page | https://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.ts | https://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 GitHub | https://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github |
| Please reload this page | https://github.com/angular/angularfire/pull/3829/files |
| src/auth/firebase.ts | https://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 GitHub | https://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github |
| Please reload this page | https://github.com/angular/angularfire/pull/3829/files |
| src/data-connect/firebase.ts | https://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 GitHub | https://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github |
| Please reload this page | https://github.com/angular/angularfire/pull/3829/files |
| src/firestore/firebase.ts | https://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 GitHub | https://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github |
| Please reload this page | https://github.com/angular/angularfire/pull/3829/files |
| src/firestore/firestore.spec.ts | https://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.ts | https://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 GitHub | https://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github |
| Please reload this page | https://github.com/angular/angularfire/pull/3829/files |
| src/remote-config/firebase.ts | https://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 GitHub | https://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github |
| Please reload this page | https://github.com/angular/angularfire/pull/3829/files |
| Please reload this page | https://github.com/angular/angularfire/pull/3829/files |
| Please reload this page | https://github.com/angular/angularfire/pull/3829/files |
|
| https://github.com |
| Terms | https://docs.github.com/site-policy/github-terms/github-terms-of-service |
| Privacy | https://docs.github.com/site-policy/privacy-policies/github-privacy-statement |
| Security | https://github.com/security |
| Status | https://www.githubstatus.com/ |
| Community | https://github.community/ |
| Docs | https://docs.github.com/ |
| Contact | https://support.github.com?tags=dotcom-footer |
Response headers:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width
URLs of crawlers that visited me.