Title: Version 5.4.2 breaks Angular Universal server rendering · Issue #2341 · angular/angularfire · GitHub
Open Graph Title: Version 5.4.2 breaks Angular Universal server rendering · Issue #2341 · angular/angularfire
X Title: Version 5.4.2 breaks Angular Universal server rendering · Issue #2341 · angular/angularfire
Description: Version info Angular: 9.0.4 Firebase: 7.9.3 AngularFire: 5.4.2 Other (e.g. Ionic/Cordova, Node, browser, operating system): How to reproduce these conditions Have an Angular Universal app that does an AngularFire query on page load. When...
Open Graph Description: Version info Angular: 9.0.4 Firebase: 7.9.3 AngularFire: 5.4.2 Other (e.g. Ionic/Cordova, Node, browser, operating system): How to reproduce these conditions Have an Angular Universal app that does...
X Description: Version info Angular: 9.0.4 Firebase: 7.9.3 AngularFire: 5.4.2 Other (e.g. Ionic/Cordova, Node, browser, operating system): How to reproduce these conditions Have an Angular Universal app that does...
Opengraph URL: https://github.com/angular/angularfire/issues/2341
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Version 5.4.2 breaks Angular Universal server rendering","articleBody":"### Version info\r\n\r\n\u003c!-- What versions of the following libraries are you using? Note that your issue may already\r\nbe fixed in the latest versions. --\u003e\r\n\r\n**Angular:**\r\n9.0.4 \r\n\r\n**Firebase:**\r\n7.9.3\r\n\r\n**AngularFire:**\r\n5.4.2\r\n\r\n**Other (e.g. Ionic/Cordova, Node, browser, operating system):**\r\n\r\n### How to reproduce these conditions\r\n\r\nHave an Angular Universal app that does an AngularFire query on page load. When you do this, you will see that `isStable` from the Angular `ApplicationRef` is immediately set to `true` at the moment of the database call.\r\n\r\nThis is a problem because it means the server response is sent back to the client BEFORE the data from the database is actually used to update the page (i.e. the server view does not contain the data even though it is returned).\r\n\r\nThis issue does not exist with Firebase `7.6.2` and AngularFire `5.3.0`. It only exists with Fireabase `7.9.3` and AngularFire `5.4.2`.\r\n\r\n**Failing test unit, Plunkr, or JSFiddle demonstrating the problem**\r\n\r\nN/A - I have this issue on a private repo, but have tested enough to confirm it almost certainly is an issue for anyone with this setup.\r\n\r\n**Steps to set up and reproduce**\r\n\r\nDo the following:\r\n\r\n1. Create an Angular Universal app with Angular 9+ and AngularFire `7.9.3`.\r\n2. In the `ngOnInit()` page lifecycle hook of any page, perform an AngularFire query. It can be any query\r\n3. Have a console.log() right after the AngularFire query completes and data is returned\r\n4. Add this code to the constructor of the page:\r\n\r\n```\r\nconstructor(ref: ApplicationRef) {\r\n ref.isStable(isStable =\u003e console.log('isStable = ' + isStable);\r\n}\r\n```\r\n\r\nWhen you do this and load the app, you will see that `isStable` is set to true BEFORE the console.log from step 3 is executed. This means the server view is returned before we have a chance to do anything with the data coming back from AngularFire.\r\n\r\n**Sample data and security rules**\r\n\r\nN/A - issue not related to data or security rules\r\n\r\n### Debug output\r\n\r\n** Errors in the JavaScript console **\r\n\r\nN/A - there is no error, it is just that the data isn't included in the server view\r\n\r\n** Output from `firebase.database().enableLogging(true);` **\r\n\r\nN/A - related to firestore, not the realtime database\r\n\r\n** Screenshots **\r\n\r\nN/A - this is not a visual issue\r\n\r\n### Expected behavior\r\n\r\nThe expected behavior is that the Angular `ApplicationRef.isStable` is not set to true until after all async is complete AND the sync code that immediately follows the async code is complete.\r\n\r\n### Actual behavior\r\n\r\nThe actual behavior is that immediately when the AngularFire query is run, `isStable` is set to true and the server response immediately returns.\r\n","author":{"url":"https://github.com/jeffwhelpley","@type":"Person","name":"jeffwhelpley"},"datePublished":"2020-03-02T20:47:46.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/2341/angularfire/issues/2341"}
| 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:bc23b974-5224-8d5a-c3ef-dbe139268103 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BE1C:E2061:C26AD0:FEFAB3:6A5B074E |
| html-safe-nonce | 900494bc850f9a4f975eaea3761011d5db5051eaaaf77edd45ca6f67176884c7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTFDOkUyMDYxOkMyNkFEMDpGRUZBQjM6NkE1QjA3NEUiLCJ2aXNpdG9yX2lkIjoiNTQ2NTQ3MjQxMTM4NTkyMzQwNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f99cadec5905f809825329018e9d27ba46ab7804ceb1b860d4690f4504d0160d |
| hovercard-subject-tag | issue:574238447 |
| 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/2341/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3d694db9e3b880d90c8e94c88b077932e257cfae81090a7f8f3c337080a1f826/angular/angularfire/issues/2341 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3d694db9e3b880d90c8e94c88b077932e257cfae81090a7f8f3c337080a1f826/angular/angularfire/issues/2341 |
| og:image:alt | Version info Angular: 9.0.4 Firebase: 7.9.3 AngularFire: 5.4.2 Other (e.g. Ionic/Cordova, Node, browser, operating system): How to reproduce these conditions Have an Angular Universal app that does... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jeffwhelpley |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| 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 | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width