angular / angularfire

Angular + Firebase = ❤️
https://firebaseopensource.com/projects/angular/angularfire2
MIT License
7.68k stars 2.19k forks source link

Memory leak at Using the AngularFireAuthModule #2559

Closed kenji-iiii closed 3 years ago

kenji-iiii commented 4 years ago

I am operating angular with SSR, but I confirmed that a memory leak occurs on GCP when AngularFireAuthModule is imported into the module.

Immediately after deployment, memory starts to increase

image

Version info Angular:10.0.4

Firebase:7.17.1

AngularFire:6.0.2

import { BrowserModule } from '@angular/platform-browser';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { TransferHttpCacheModule } from '@nguniversal/common';
import { AppRoutingModule } from './app-routing.module';
import { environment } from './../environments/environment';

import { AppComponent } from './app.component';
import { TopComponent } from './pages/top/top.component';

// Firebase
import { AngularFireModule } from '@angular/fire';
import { AngularFireAuthModule } from '@angular/fire/auth';
import { AngularFirestoreModule } from '@angular/fire/firestore';
import { AngularFirePerformanceModule } from '@angular/fire/performance';

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

@NgModule({
  declarations: [
    AppComponent,
    TopComponent,
  ],
  imports: [
    CommonModule,
    SharedMetaUtilModule,
    AngularFireModule.initializeApp(environment.firebase),
    AngularFireAuthModule,  // adding this line creates the memory leak
    AngularFirestoreModule,
    AngularFirePerformanceModule,
    BrowserModule.withServerTransition({ appId: 'serverApp' }),
    TransferHttpCacheModule,
    BrowserAnimationsModule,
  ],
  providers: [
    {
      provide: HTTP_INTERCEPTORS,
      useClass: BaseUrlInterceptor,
      multi: true,
    },
  ],
  bootstrap: [AppComponent],
})
export class AppModule {}

`
karmasakshi commented 4 years ago

I think the problem is within the main module itself. I was able to reproduce this with AngularFireAnalytics module. Have a look at the issue I raised here: https://github.com/angular/angularfire/issues/2550

jamesdaniels commented 3 years ago

I'll look into this next patch, I agree #2550 is likely the base issue. Closing as dup. A thought had occurred that I saw RXJS recently closed some issues regarding issues like this, so maybe there's an underlying bug in the version you have or how we're implementing. I'll investigate for a 6.1.1 release though.

jamesdaniels commented 3 years ago

Also seems like Auth made some fixes here, maybe this is resolved entirely now.