From ff5b78eb2452c2de8c176329d41e51d122878244 Mon Sep 17 00:00:00 2001 From: Feiyang1 Date: Tue, 11 Aug 2020 21:58:11 -0700 Subject: [PATCH] fix the delete loop --- packages/component/src/provider.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/component/src/provider.ts b/packages/component/src/provider.ts index 409049e8969..175ec278e6d 100644 --- a/packages/component/src/provider.ts +++ b/packages/component/src/provider.ts @@ -174,11 +174,20 @@ export class Provider { ...services .filter(service => 'INTERNAL' in service) // legacy services // eslint-disable-next-line @typescript-eslint/no-explicit-any - .map(service => (service as any).INTERNAL!.delete()) - // ...services - // .filter(service => 'delete' in service) // next services - // // eslint-disable-next-line @typescript-eslint/no-explicit-any - // .map(service => (service as any).delete()) + .map(service => (service as any).INTERNAL!.delete()), + ...services + // eslint-disable-next-line @typescript-eslint/no-explicit-any + .filter( + service => + 'delete' in service && + this.component && + // TODO: remove !== 'app' when modular SDKs become official + // People call app.delete() to trigger provider.delete() for all registered components, so + // we don't call delete() on legacy FirebaseApp to avoid getting into a loop. + (this.component.name as any) !== 'app' + ) // modular services + // eslint-disable-next-line @typescript-eslint/no-explicit-any + .map(service => (service as any).delete()) ]); }