Skip to content

Firestore does not work with Angular Universal and AngularFire2 on Firebase Functions #1745

@phpet

Description

@phpet

Angular:
6.0.6

Firebase:
5.0.4

AngularFire:
5.0.0-rc.10

Other (e.g. Ionic/Cordova, Node, browser, operating system):
OS: Windows 10
Node version: 8.11.2

Steps to set up and reproduce

Clone this repository: https://github.com/phpet/ssr

npm run build:ssr
firebase deploy

Debug output

** Errors in the Firebase Functions logs **

Unhandled Promise rejection: Cannot read property 'firestore' of undefined ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot read property 'firestore' of undefined
    at new AngularFirestore (/user_code/node_modules/angularfire2/bundles/firestore.umd.js:148:29)
    at _createClass (/user_code/node_modules/@angular/core/bundles/core.umd.js:8204:20)
    at _createProviderInstance$1 (/user_code/node_modules/@angular/core/bundles/core.umd.js:8166:26)
    at resolveNgModuleDep (/user_code/node_modules/@angular/core/bundles/core.umd.js:8129:21)
    at NgModuleRef_.get (/user_code/node_modules/@angular/core/bundles/core.umd.js:8837:16)
    at resolveDep (/user_code/node_modules/@angular/core/bundles/core.umd.js:9202:45)
    at createClass (/user_code/node_modules/@angular/core/bundles/core.umd.js:9076:85)
    at createDirectiveInstance (/user_code/node_modules/@angular/core/bundles/core.umd.js:8959:20)
    at createViewNodes (/user_code/node_modules/@angular/core/bundles/core.umd.js:10179:36)
    at createRootView (/user_code/node_modules/@angular/core/bundles/core.umd.js:10093:5) TypeError: Cannot read property 'firestore' of undefined
    at new AngularFirestore (/user_code/node_modules/angularfire2/bundles/firestore.umd.js:148:29)
    at _createClass (/user_code/node_modules/@angular/core/bundles/core.umd.js:8204:20)
    at _createProviderInstance$1 (/user_code/node_modules/@angular/core/bundles/core.umd.js:8166:26)
    at resolveNgModuleDep (/user_code/node_modules/@angular/core/bundles/core.umd.js:8129:21)
    at NgModuleRef_.get (/user_code/node_modules/@angular/core/bundles/core.umd.js:8837:16)
    at resolveDep (/user_code/node_modules/@angular/core/bundles/core.umd.js:9202:45)
    at createClass (/user_code/node_modules/@angular/core/bundles/core.umd.js:9076:85)
    at createDirectiveInstance (/user_code/node_modules/@angular/core/bundles/core.umd.js:8959:20)
    at createViewNodes (/user_code/node_modules/@angular/core/bundles/core.umd.js:10179:36)
    at createRootView (/user_code/node_modules/@angular/core/bundles/core.umd.js:10093:5)

** Screenshots **

https://imgur.com/5Ybcdw5

Expected behavior

Injecting the AngularFirestore variable in the constructor of the AppComponent class should work without errors.

Actual behavior

The browser shows a 504 Gateway Time-out error and the Firebase Functions logs show the error above.

I also tried with the latest version of AngularFire2 5.0.0-rc.11 and it doesn't work either.

Interesting facts

I tried replacing the angularfire2 library with angularfire-lite and it worked, so it's definitely related to the combination of AngularFire2 and Firestore.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions