File tree 2 files changed +14
-5
lines changed 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @firebase/app ' : patch
3
+ ' firebase ' : patch
4
+ ---
5
+
6
+ Guard the use of ` FinalizationRegistry ` in ` FirebaseServerApp ` initialization based on the availability of ` FinalizationRegistry ` in the runtime.
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ export class FirebaseServerAppImpl
32
32
implements FirebaseServerApp
33
33
{
34
34
private readonly _serverConfig : FirebaseServerAppSettings ;
35
- private _finalizationRegistry : FinalizationRegistry < object > ;
35
+ private _finalizationRegistry : FinalizationRegistry < object > | null ;
36
36
private _refCount : number ;
37
37
38
38
constructor (
@@ -67,9 +67,12 @@ export class FirebaseServerAppImpl
67
67
...serverConfig
68
68
} ;
69
69
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
+ }
73
76
74
77
this . _refCount = 0 ;
75
78
this . incRefCount ( this . _serverConfig . releaseOnDeref ) ;
@@ -97,7 +100,7 @@ export class FirebaseServerAppImpl
97
100
return ;
98
101
}
99
102
this . _refCount ++ ;
100
- if ( obj !== undefined ) {
103
+ if ( obj !== undefined && this . _finalizationRegistry !== null ) {
101
104
this . _finalizationRegistry . register ( obj , this ) ;
102
105
}
103
106
}
You can’t perform that action at this time.
0 commit comments