Skip to content

Commit 256814a

Browse files
committed
Guard _finalizationRegistry based on availability.
1 parent b09a267 commit 256814a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

packages/app/src/firebaseServerApp.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class FirebaseServerAppImpl
3232
implements FirebaseServerApp
3333
{
3434
private readonly _serverConfig: FirebaseServerAppSettings;
35-
private _finalizationRegistry: FinalizationRegistry<object>;
35+
private _finalizationRegistry: FinalizationRegistry<object> | null;
3636
private _refCount: number;
3737

3838
constructor(
@@ -67,9 +67,12 @@ export class FirebaseServerAppImpl
6767
...serverConfig
6868
};
6969

70-
this._finalizationRegistry = new FinalizationRegistry(() => {
71-
this.automaticCleanup();
72-
});
70+
this._finalizationRegistry = null;
71+
if (typeof FinalizationRegistry !== 'undefined') {
72+
this._finalizationRegistry = new FinalizationRegistry(() => {
73+
this.automaticCleanup();
74+
});
75+
}
7376

7477
this._refCount = 0;
7578
this.incRefCount(this._serverConfig.releaseOnDeref);
@@ -97,7 +100,7 @@ export class FirebaseServerAppImpl
97100
return;
98101
}
99102
this._refCount++;
100-
if (obj !== undefined) {
103+
if (obj !== undefined && this._finalizationRegistry !== null) {
101104
this._finalizationRegistry.register(obj, this);
102105
}
103106
}

0 commit comments

Comments
 (0)