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

ionic build --prod gets stuck after copying because of @firebase/app #1422

Closed
westphalen opened this Issue Apr 24, 2018 · 27 comments

Comments

Projects
None yet
@westphalen
Copy link

westphalen commented Apr 24, 2018

Short description of the problem:

There seems to have been some issues running ionic build --prod with certain version of @ionic/app-scripts and webpack back in late 2017, but I'm experiencing this issue with a new project on latest versions in 2018.

Specifically, the build process gets stuck right after copy finished. Eventually (about half an hour with default settings) it will exhaust memory and crash.

The reason this started happening for me was firebase init functions creating a functions directory in my project. This should be ok, but for some reason Webpack picks it up for my ionic build --prod and goes amok.

What behavior are you expecting?

functions directory is unrelated and thus ignored by app-scripts.

Steps to reproduce:

  1. Start a new Ionic project.
  2. firebase init functions
  3. ionic build --prod

Which @ionic/app-scripts version are you using?
3.1.9

Other information:

Either webpack should not touch any files not related specifically to the Ionic project, or we should be able to configure the scope somehow.

@westphalen

This comment has been minimized.

Copy link
Author

westphalen commented Apr 25, 2018

It seems the reported issue had nothing to do with firebase functions after all.

The real culprit was having the Ionic project depend on @firebase/app@^0.1.10.
Getting rid of that dependency immediately fixed the issue.

webpack finished in 67s

@westphalen westphalen closed this Apr 25, 2018

@westphalen westphalen changed the title ionic build --prod gets stuck after copying because of firebase functions ionic build --prod gets stuck after copying because of @firebase/app Apr 25, 2018

@Bengejd

This comment has been minimized.

Copy link

Bengejd commented May 1, 2018

@westphalen how did you manage to get rid of the @firebase/app@^0.1.10 dependency without breaking everything?

@westphalen

This comment has been minimized.

Copy link
Author

westphalen commented May 2, 2018

If you depend on it directly, I have no idea.

It was just in my project to support angularfire and firebase.

After upgrading everything, and then downgrading firebase to 4.12.1, I could build my app without @firebase/app@^0.1.10.

Reason for the downgrade: angular/angularfire2#1576

@vincent-cm

This comment has been minimized.

Copy link

vincent-cm commented Jun 11, 2018

@tahminabs23

This comment has been minimized.

Copy link

tahminabs23 commented Jun 19, 2018

Unfortunately, I can not downgrade to firebase 4.12.1. Because I am depending on version 5. Has there any option to proceed to build without downgrading?

@westphalen

This comment has been minimized.

Copy link
Author

westphalen commented Jun 19, 2018

@tahminabs23 Have you tried with angularfire2 5.0.0-rc-7.0?

@tahminabs23

This comment has been minimized.

Copy link

tahminabs23 commented Jun 20, 2018

@westphalen yes, I tried with 5.0.0-rc.7 and firebase/app 0.1.10, but still gets stuck after copying when I use --prod

@tahminabs23

This comment has been minimized.

Copy link

tahminabs23 commented Jun 20, 2018

Now I tried with "angularfire2": "^5.0.0-rc.7.0-next", "firebase": "^4.13.1", and it generates new issue angular/zone.js#1081

@Usamaliaquat123

This comment has been minimized.

Copy link

Usamaliaquat123 commented Jul 26, 2018

@westphalen thank bro it works for me ...! firebase@4.12.1 💯 💯 💯 💯 💯 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 thanks dude ...

@germanriverahdez

This comment has been minimized.

Copy link

germanriverahdez commented Aug 7, 2018

Yes, downgrade to firebase@4.12.1.
This fix the problem for me.

Thank you @westphalen

@saryuvc

This comment has been minimized.

Copy link

saryuvc commented Aug 31, 2018

Hello,

Please remove www folder,node modules,platforms, and npm install

please note : I have updated to ionic 4 and cordova 8.

this solved my issue.

@praveenpds

This comment has been minimized.

Copy link

praveenpds commented Sep 3, 2018

After copy, webpack finished command is not displayed and freezes terminal.

I m using FCM push notification and I'm facing a similar issue. Any solutions?

I have tried these three solutions :

https://forum.ionicframework.com/t/ionic-build-prod-stuck-at-copy-finished-in/129732/11

https://stackoverflow.com/questions/26094420/fatal-error-call-and-retry-last-allocation-failed-process-out-of-memory

#1426

project property :

target=android-25
android.library.reference.1=CordovaLib
cordova.gradle.include.1=phonegap-plugin-push/coseionic2691015-push.gradle
cordova.system.library.1=com.android.support:support-v4:24.1.1+
cordova.system.library.2=com.android.support:support-v4:24.1.1+
cordova.system.library.3=com.android.support:support-v13:23+
cordova.system.library.4=com.google.android.gms:play-services-gcm:11+
cordova.system.library.5=me.leolin:ShortcutBadger:1.1.14@aar
cordova.system.library.6=com.android.support:support-v4:+

@r6047736

This comment has been minimized.

Copy link

r6047736 commented Sep 6, 2018

If anyone using firbase@5.4.2 and occurs the problem, downgrade to 5.4.1 works for me.

@kevinrodriguez-io

This comment has been minimized.

Copy link

kevinrodriguez-io commented Sep 9, 2018

Unfortunately,
If i downgrade to 4.12.1

i get the following error from angularfire2

[23:01:04]  typescript: ...darkn/projects/IONIC/airmedix/node_modules/angularfire2/firebase.app.module.d.ts, line: 2
            Module '"C:/Users/darkn/projects/IONIC/airmedix/node_modules/firebase/index"' has no exported member
            'functions'.

       L1:  import { InjectionToken } from '@angular/core';
[23:01:04]  typescript: C:/Users/darkn/projects/IONIC/airmedix/node_modules/angularfire2/auth/auth.d.ts, line: 12
[23:01:04]  ionic-app-script task: "build"
[23:01:04]  Error: The Angular AoT build failed. See the issues above
Error: The Angular AoT build failed. See the issues above
    at C:\Users\darkn\projects\IONIC\airmedix\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:232:55
    at step (C:\Users\darkn\projects\IONIC\airmedix\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:32:23)
    at Object.next (C:\Users\darkn\projects\IONIC\airmedix\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:13:53)
    at fulfilled (C:\Users\darkn\projects\IONIC\airmedix\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:4:58)
       L2:  import { app, auth, database, firestore, functions, messaging, storage } from 'firebase';
       L3:  export declare type FirebaseOptions = {

            Namespace 'firebase.auth' has no exported member 'IdTokenResult'.

      L11:  readonly user: Observable<User | null>;
      L12:  readonly idTokenResult: Observable<auth.IdTokenResult | null>;
      L13:  constructor(options: FirebaseOptions, nameOrConfig: string | FirebaseAppConfig | undefined, platformId: Object, zone: NgZone);

I also downgraded to angularfire2 5.0.0-rc.7 and get "Zone already loaded" error which doesn't allow my app to run, i also had to change some calls for fireAuth.user...

@kevinrodriguez-io

This comment has been minimized.

Copy link

kevinrodriguez-io commented Sep 9, 2018

Update: See my latest comment, it works better than this solution.

Ok, thanks to @tahminabs23 i managed to find a solution.

This combination is working fine for me at the moment.

npm i --save firebase@4.12.1
npm i --save angularfire2@5.0.0-rc4

I had to change some code for the Auth validation:

From:

const userSubscription = angularFireAuth.user.subscribe(user => {
  // Some code here
  userSubscription.unsubscribe();
});

To

const unsubscribe = angularFireAuth.auth.onAuthStateChanged(user => {
  // Some code here
  unsubscribe();
});
@saumya04

This comment has been minimized.

Copy link

saumya04 commented Oct 23, 2018

The combination of these 2 versions solved the issue for me:

firebase - 4.12.1
angularfire2 - 5.0.0-rc.4

npm i firebase@4.12.1 angularfire2@5.0.0-rc.4 --save

@WooWapDaBug

This comment has been minimized.

Copy link

WooWapDaBug commented Nov 5, 2018

@saumya04 Is that combination working? I get this warning:

npm WARN angularfire2@5.0.0-rc.4 requires a peer of firebase@^4.5.0 but none is installed

@saumya04

This comment has been minimized.

Copy link

saumya04 commented Nov 5, 2018

@WooWapDaBug Yup the combination is working for me...

@WooWapDaBug

This comment has been minimized.

Copy link

WooWapDaBug commented Nov 5, 2018

@saumya04 You are right, now it is working. I don't know what I was doing wrong

@kevinrodriguez-io

This comment has been minimized.

Copy link

kevinrodriguez-io commented Nov 11, 2018

I have to tell that this is not the best solution.

The best solution is to stop using the old angularfire2 namespace and switch to latest firebase, @angular/fire (this one instead of angularfire2) releases . At some point if you need offline usage you will have to try angularfire2-offline and that package is no longer mantained, so you will maybe want to try firestore, which is not supported in the angularfire2@5.0.0-rc4, firebase@4.5.0 combination.

My fix (which i think is the best for this specific scenario) was to update to latest @angular/fire and firebase and update all my imports... I also remember having some issues with the rxjs compat package but those are gone now.

My current working packages.json dependencies look like this:

{
    "@angular/common": "5.2.11", (other angular dependencies look like this)
    ... (Others)
    "@angular/fire": "^5.0.2",
    "firebase": "^5.5.4",
    "rxjs": "^6.2.2",
    "rxjs-compat": "^6.2.2",
    "zone.js": "0.8.26"
}

You have to uninstall angularfire2 and firebase and reinstall with
npm i @angular/fire firebase --save

That solution worked for me and now i enjoy the latest features and firestore support with offline usage.

@adamduren

This comment has been minimized.

Copy link

adamduren commented Nov 11, 2018

@kevinrodriguez-io FWIW I have this issue occur without any library other than "firebase": "^5.5.2".

@franzisk

This comment has been minimized.

Copy link

franzisk commented Nov 19, 2018

@westphalen thank bro it works for me ...! firebase@4.12.1 💯 💯 💯 💯 💯 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 🥇 thanks dude ...

Where did you change it to 4.12.1?

@courageDeveloper

This comment has been minimized.

Copy link

courageDeveloper commented Dec 3, 2018

I have to tell that this is not the best solution.

The best solution is to stop using the old angularfire2 namespace and switch to latest firebase, @angular/fire (this one instead of angularfire2) releases . At some point if you need offline usage you will have to try angularfire2-offline and that package is no longer mantained, so you will maybe want to try firestore, which is not supported in the angularfire2@5.0.0-rc4, firebase@4.5.0 combination.

My fix (which i think is the best for this specific scenario) was to update to latest @angular/fire and firebase and update all my imports... I also remember having some issues with the rxjs compat package but those are gone now.

My current working packages.json dependencies look like this:

{
    "@angular/common": "5.2.11", (other angular dependencies look like this)
    ... (Others)
    "@angular/fire": "^5.0.2",
    "firebase": "^5.5.4",
    "rxjs": "^6.2.2",
    "rxjs-compat": "^6.2.2",
    "zone.js": "0.8.26"
}

You have to uninstall angularfire2 and firebase and reinstall with
npm i @angular/fire firebase --save

That solution worked for me and now i enjoy the latest features and firestore support with offline usage.

@kevinrodriguez-io when you did this, your project stopped hanging when you used the production flag?

@courageDeveloper

This comment has been minimized.

Copy link

courageDeveloper commented Dec 3, 2018

@westphalen what version of angularfire2 are you using?

@courageDeveloper

This comment has been minimized.

Copy link

courageDeveloper commented Dec 3, 2018

Finally it worked for me, i downgraded my @ionic/app-scripts to 3.1.11 and also added @firebase/database@0.2.1. These two links really helped me out:
#1426
firebase/firebase-js-sdk#714 (comment)

@mattdodge

This comment has been minimized.

Copy link

mattdodge commented Dec 21, 2018

@courageDeveloper what did your package.json ultimately look like? I'm running into this issue now. Did you install @firebase/database@0.2.1 and also @angular/fire? Or were you using the old angularfire2 library?

@mattdodge

This comment has been minimized.

Copy link

mattdodge commented Dec 21, 2018

I was able to get it (like most people it seems...) after trying a bunch of different solutions. For me, the key seemed to be installing @angular-devkit/build-optimizer. I am not including angularfire2 or @firebase/database.

Here are the important parts of my package.json:

{
  "dependencies": {
    "@angular-devkit/build-optimizer": "0.6.8",
    "@angular/fire": "^5.1.1",
    "firebase": "^5.7.1",
    "rxjs": "^6.0",
    "rxjs-compat": "^6.3.3"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.1.11"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment