Title: "Warning: Firebase API called outside injection context" on non-async functions · Issue #3611 · angular/angularfire · GitHub
Open Graph Title: "Warning: Firebase API called outside injection context" on non-async functions · Issue #3611 · angular/angularfire
X Title: "Warning: Firebase API called outside injection context" on non-async functions · Issue #3611 · angular/angularfire
Description: This is related to #3605 and #3607 where a workaround has been suggested #3590 (comment). But my question is specifically for non-async functions. First of all, thank you @jamesdaniels for the new guide at https://github.com/angular/angu...
Open Graph Description: This is related to #3605 and #3607 where a workaround has been suggested #3590 (comment). But my question is specifically for non-async functions. First of all, thank you @jamesdaniels for the new ...
X Description: This is related to #3605 and #3607 where a workaround has been suggested #3590 (comment). But my question is specifically for non-async functions. First of all, thank you @jamesdaniels for the new ...
Opengraph URL: https://github.com/angular/angularfire/issues/3611
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"\"Warning: Firebase API called outside injection context\" on non-async functions","articleBody":"This is related to https://github.com/angular/angularfire/issues/3605 and https://github.com/angular/angularfire/issues/3607 where a workaround has been suggested https://github.com/angular/angularfire/pull/3590#issuecomment-2581455741.\nBut my question is specifically for non-async functions.\n\nFirst of all, thank you @jamesdaniels for the new guide at https://github.com/angular/angularfire/blob/main/docs/zones.md.\n(I think the doc would benefit from some concrete examples.)\n\nMy understanding is that direct calls to docData where it's called say from within an rxjs switchMap, should be wrapped in `runInInjectionContext`\n```typescript\n loadDoc\u003cT>(docPath: string): Observable\u003cT | undefined> {\n return docData\u003cT>(doc(this.firestore, docPath));\n }\n```\n↓↓↓\n```typescript\n private injectionContext = inject(EnvironmentInjector);\n\n loadDoc\u003cT>(docPath: string): Observable\u003cT | undefined> {\n return runInInjectionContext(this.injectionContext, () => {\n return docData\u003cT>(doc(this.firestore, docPath));\n });\n }\n```\n\nHowever, even after adding `runInInjectionContext` wrappers for all load & set operations, there are still warnings from functions that are not async in nature such as `where, snapToData, serverTimestamp, increment, orderBy, limit`:\n\n\n\nThis is because [`tools/build.ts`](https://github.com/angular/angularfire/blob/8ce95bf6f8de590f84206ae0c75e39ade458abc3/tools/build.ts) is applying `ɵzoneWrap` to every Firebase function:\n\nhttps://github.com/angular/angularfire/blob/8ce95bf6f8de590f84206ae0c75e39ade458abc3/src/firestore/rxfire.ts#L22-L27\n\nhttps://github.com/angular/angularfire/blob/8ce95bf6f8de590f84206ae0c75e39ade458abc3/src/firestore/firebase.ts#L76-L144\n\nShould AngularFire take a more granular approach and throw warnings only on async functions such as `docData` to avoid extraneous warnings?","author":{"url":"https://github.com/anisabboud","@type":"Person","name":"anisabboud"},"datePublished":"2025-01-12T13:36:46Z","url":"https://github.com/angular/angularfire/issues/3611"}
| 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 | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:59841afc-cf3a-bdab-5363-dda313d6e5bf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9A30:3BA415:A5883:D93C7:6B03602D |
| html-safe-nonce | f43958ff42bff7dfc75d5571144d178560258ece0320a04aa4b6d43054672293 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTMwOjNCQTQxNTpBNTg4MzpEOTNDNzo2QjAzNjAyRCIsInZpc2l0b3JfaWQiOiI3MTM4OTg2MDA4NTk4NzY1NjEzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7f231bf972296be94b74a9f67f64fb4f37ade53561e1ddfc87af6e88b25f2576 |
| hovercard-subject-tag | issue:2782490199 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/angular/angularfire/3611/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dafbf6289646c6336172425c2004673fefadfffb919452b0d0d36125f87fc7fa/angular/angularfire/issues/3611 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dafbf6289646c6336172425c2004673fefadfffb919452b0d0d36125f87fc7fa/angular/angularfire/issues/3611 |
| og:image:alt | This is related to #3605 and #3607 where a workaround has been suggested #3590 (comment). But my question is specifically for non-async functions. First of all, thank you @jamesdaniels for the new ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | anisabboud |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| 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 |
| disable-turbo | false |
| 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 |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width