Skip to content
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

fix: server app should initialize even if FinalizationRegistry is unsupported #8320

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/large-boats-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@firebase/app': patch
---

FirebaseServerApp should initialize even if FinalizationRegistry is unsupported by runtime
10 changes: 6 additions & 4 deletions packages/app/src/firebaseServerApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class FirebaseServerAppImpl
implements FirebaseServerApp
{
private readonly _serverConfig: FirebaseServerAppSettings;
private _finalizationRegistry: FinalizationRegistry<object>;
private _finalizationRegistry!: FinalizationRegistry<object>;
private _refCount: number;

constructor(
Expand Down Expand Up @@ -67,9 +67,11 @@ export class FirebaseServerAppImpl
...serverConfig
};

this._finalizationRegistry = new FinalizationRegistry(() => {
this.automaticCleanup();
});
if (typeof FinalizationRegistry !== 'undefined') {
this._finalizationRegistry = new FinalizationRegistry(() => {
this.automaticCleanup();
});
}

this._refCount = 0;
this.incRefCount(this._serverConfig.releaseOnDeref);
Expand Down
Loading