-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Angular Ivy 9.0 stable and angularfire RC1 using Firestore have trouble with Universal #2320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@hiepxanh Found a solution? |
Thanks for digging in here, I’ll spend some time debugging too. I’ll want to address for 6.0 stable. |
@mazlano27 not yet sir. Still digging and stop at there. maybe the problem is UMD and ESM2015 but I don't have experience about this |
@jamesdaniels you're welcome, I'll do anything you need if you want me to help |
Thank you. Are you able to SSR Angular 9 with @angular/fire@5.4.2? I am getting the same/similar errors you have documented above and am unable to find a working solution |
@mazlano27 no sir, I belive this problem is will be resolve soon, just maybe some conflict on the module loader conflict. |
keep digging deeper, look like I found the loop: |
@hiepxanh I was successful disabling Ivy. tsconfig.json
server.ts
angular.json > architect.server.options
|
I understand sir @tiagorvs, but I would like to work with ivy to get the best performance since angular 9 enable ivy by default |
Is there any workaround available today? (I've tried the externalDependencies with grpc but it was not successful as previously mentioned by @hiepxanh ) |
Hi @tiagorvs, I tried your exact same solution (deactivating Ivy - not forgetting to change the server.ts & externalDependencies) and this was not working for us. On our Google Run instance logs, we have the following stacktrace :
For information : this error does not occur when we test SSR on localhost using the command mentioned in the official documentation : npm run build:ssr && npm run serve:ssr "@angular/core": "9.0.0", You said
Are you able to give us an approximate date on when the 6.0 stable will be live? is it few days or weeks? Based on your answer, we will do or not a rollback to Angular 8 because it does not seem we can do SSR with Angular 9 and Firestore. |
@vroussel35 I suggest you rollback to angular 8 since he will be busy to update manything. everything will be alright after I test his new update |
I am aiming to achieve success bundling us with Angular 9 SSR within a week. Depending on the day of the week I get it merged, other issues in the meantime, or how big that particular change is I may decide to cut another RC before 6.0 drops on |
Thanks @hiepxanh and @jamesdaniels for your quick replies - we will do our rollback to Angular 8, waiting for the 6.0 stable. Thanks for all the great work you do ! |
any update on a working ssr with the latest version and angular 9 ivy? |
After much suffering I've managed to get this working! I have a couple more things to clean up and will be cutting a new RC shortly. I had to add It's very clear that NGCC does not like how Firestore is bundled. I'll grab some time with the JS SDK team when opportune. |
Congratulation for your contribution. :D
don't worrry, let's roll out and see how it work. I will test this as soon as you release |
Hoping for a quick release 🤞 |
try the canary version for now. |
@tiagorvs tried still getting the same error. ..
|
Getting this error when trying to pre-render with @angular/fire@canary → Unhandled Promise rejection: Cannot read property 'id' of undefined ; Zone: ; Task: Promise.then ; Value: TypeError: Cannot read property 'id' of undefined Is pre-rendering with Angular 9 + Firestore possible yet? |
Meanwhile managing with the firestore rest API https://firebase.google.com/docs/firestore/use-rest-api documentation is terrible, but if you have simple use cases, you can save 60kb of bundle size |
Hi @jamesdaniels - without any pressure, are you able to give us a rough estimate of when @angular/fire v6 should be available ? (we need this input to plan our developments accordingly). |
Hi @jamesdaniels - is everything OK for you? Are you able to give us some news regarding the next release date? |
@google-admin we could use some extra resources here |
@vroussel35
|
Hi Ruben Heymans, I tried that several times and still does not work. |
Please suggest which firebase version match the Angular 9 , good in SSR, I have problem with this any try many days can't figure it out. I also use google map api and geofirex, stuck in serve:ssr. Any help. I used |
Add |
after I added @firebase/firestore to "package.json".dependencies |
@fayeyen they close my issues, so I close my PR #2372 SOLUTION:Description Code sample SNIPPET:1. Edit fileInsert polyfills at the top of file
2. Setup Firebase detail
3. Running
|
Any solution regarding to this error?
//dist/server/main.js:23730 Error: ENOENT: no such file or directory, open 'google/protobuf/api.proto' |
@hiepxanh thank you! I'm trying your git version, is it an empty project which work on SSR? |
Thank you for help, the seed seem's fine. But when I added the auth and storage module in app.module.ts it came out with error |
Thank you! It works! by upgrade the firebase version |
@fayeyen thank you. You're welcome. Please share your solution, so other people can get help from your answer |
@FredvanRijswijk Root route resolvers easily break the entire server. |
Hey @james, I've gone back and tried to update the firebase package to 7.15.1 and the error "app.firestore is not a function" still persists. As before, falling back to 7.8.0 fixes the issue. What update can we make to have pre-rendering working for newer firebase versions? Thank you |
Hi everyone, We want to start the migration to Angular 9 for our platform which is using SSR + Angularfire. Simple question : Is "Angular 9 + SSR + Angularfire" working? Looking at all the comments above, I'm not sure if this setup is working for anyone. Would be great to know before starting spending time and money on this migration. Thanks. |
Yes it's worked but u can wait on angularfire 6.1 there are little bugs but workaround is possible to getting works |
It definitely works and I have deployed an app to production, there are just so many little things you have to get right or page won't load (eg you need to only execute anything auth related if browser), data from database won't get retrieved in time to be SSR'd (a task scheduler may be needed), or a number of other things you won't find in any documentation or tutorials floating around. I spent weeks getting mine working with my particular setup. But it is possible. |
Can you share the details or update the documentations @epiphanatic ? |
@yasinkocak well, part of what I'm getting at here is that it's not that simple. I would love to write a Medium article, but I can't just write up a general solution because 1) people have very different setups, and 2) all of this keeps changing so fast (eg what external dependencies to include or not and which exact package name, among others). You simply have to put in the time reading SO regarding specific issues you are facing, understanding the specifics of how each individual piece works, comparing all that to the exact versions of things being used in examples you see, and so on. Maybe soon SSR + Firebase + SEO (another issue all itself) will be a simple plug and play thing, but for now it is not. |
@epiphanatic did U try this #2320 (comment) |
Seeing the same issue here - did you find a solution? |
That particular error happens when you don't have @firebase/firestore added to your module. @rvbiljouw |
Hi @epiphanatic: are you able to show us a demo or a way to do it for the "data from database won't get retrieved in time to be SSR'd (a task scheduler may be needed)" as we are facing timeout errors since we've updated to angularfire 6+. Can you confirm that you were successful with a simple task like retrieving data from firestore (using promise or observable) and SSR'd them? |
@vroussel35 yes, I am able to anything that you would normally do with the database and SSR will work as well as being able to retrieve metadata (if you've set that up in your code). I just followed this https://stackoverflow.com/questions/47151811/server-does-not-wait-till-http-call-completes-before-rendering-angular-4-serve. Just wrap whatever DB call you want to be SSRd or put in metadata in that service. I'm not saying this is the best way, or that it can't work without it, I just personally could not find another way to do it if the goal is to do this stuff with dynamic content / routes. But from what I understand, you could do all this otherwise if you are using prerendering and content / routes are known beforehand (see fireship.io). It would be nice if the AngularFire team could build something like this in assuming this is indeed a requirement and not just my amateur-ness ;) |
Sorry to dig this up, but I'm having issues with firebase, @angular/fire and Universal. It was working for me for following versions:
Now I have updated to the latest 6.1.1 and 8.1.1 accordingly and when I open SSR built page I get this error in server console:
Any ideas what could this be? My app is rather basic :( |
I faced a similar issue. 2 things helped me:
|
@waterplea Make sure you update the way you import firebase to this: import firebase from 'firebase/app'; |
@jdgamble555 I did update it this way in my login component, so I can call import 'firebase/firestore'; Do I need to change it somehow? @mazlano27 If I do that I'm getting this error when I open route that uses firestore:
|
All right, this issue has helped me: Apparently, you now need to also add |
Hi there. A lot of content to consume on this page and I'm a noob when it comes to SSR. Is the conclusion that you get this error because there are files required for firebase (e.g. I've added the two dependencies above in the server block in my |
Version info
Angular:
"@angular/animations": "~9.0.0", "@angular/cdk": "^9.0.0", "@angular/common": "~9.0.0", "@angular/compiler": "~9.0.0", "@angular/core": "~9.0.0",
Firebase:
AngularFire:
How to reproduce these conditions
stackbliz
github
project link will be delete after resolve this issue
Steps to set up and reproduce
after adding Angularfire, it's work normally. But when I start with Universal build, it have problem, clone project and start:
npm run dev:ssr
Debug output
** Screenshots **

after comment firebase library:

look like the error disappear but sure. angularfire cannot run without
firebase/firestore
Expected behavior
not have error when building with universal
Actual behavior
build not succesful
already read about:
#2284
angular issue #34544
#2280
i'm starting desperated after 5 hours
Updated
universal #1207 suggest adding this but it not work:
Updated 1
#2284 suggest adding
"@angular/fire/firestore"
seem work but got other error:Reference to this update 2
update 3:
add
"bundleDependencies": true
toangular.json
then runnpm run build:ssr && npm run serve:ssr
having this issues. guest that relate to this #2280ERROR Error: inject() must be called from an injection context
solution: https://github.com/hiepxanh/angularfire2/blob/a45e0ad4f1c918e78a1610d2b73dee3cc9b1f6b1/docs/universal/getting-started.md
The text was updated successfully, but these errors were encountered: