File tree 2 files changed +15
-8
lines changed
2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -248,14 +248,14 @@ export function initializeServerApp(
248
248
249
249
// Build an app name based on a hash of the configuration options.
250
250
const nameObj = {
251
- _serverAppConfig,
251
+ ... _serverAppConfig ,
252
252
...appOptions
253
253
} ;
254
254
255
255
// However, Do not mangle the name based on releaseOnDeref, since it will vary between the
256
256
// construction of FirebaseServerApp instances. For example, if the object is the request headers.
257
- if ( nameObj . _serverAppConfig . releaseOnDeref !== undefined ) {
258
- delete nameObj . _serverAppConfig . releaseOnDeref ;
257
+ if ( nameObj . releaseOnDeref !== undefined ) {
258
+ delete nameObj . releaseOnDeref ;
259
259
}
260
260
261
261
const hashCode = ( s : string ) : number => {
Original file line number Diff line number Diff line change @@ -66,22 +66,25 @@ export class FirebaseServerAppImpl
66
66
...serverConfig
67
67
} ;
68
68
69
- this . _finalizationRegistry = new FinalizationRegistry (
70
- this . automaticCleanup
71
- ) ;
69
+ this . _finalizationRegistry = new FinalizationRegistry ( ( ) => {
70
+ this . automaticCleanup ( ) ;
71
+ } ) ;
72
72
73
73
this . _refCount = 0 ;
74
74
this . incRefCount ( this . _serverConfig . releaseOnDeref ) ;
75
75
76
76
// Do not retain a hard reference to the dref object, otherwise the FinalizationRegisry
77
77
// will never trigger.
78
78
this . _serverConfig . releaseOnDeref = undefined ;
79
+ serverConfig . releaseOnDeref = undefined ;
79
80
}
80
81
81
82
get refCount ( ) : number {
82
83
return this . _refCount ;
83
84
}
84
85
86
+ // Increment the reference count of this server app. If an object is provided, register it
87
+ // with the finalization registry.
85
88
incRefCount ( obj : object | undefined ) : void {
86
89
if ( this . isDeleted ) {
87
90
return ;
@@ -92,15 +95,19 @@ export class FirebaseServerAppImpl
92
95
}
93
96
}
94
97
98
+ // Decrement the reference count.
95
99
decRefCount ( ) : number {
96
100
if ( this . isDeleted ) {
97
101
return 0 ;
98
102
}
99
103
return -- this . _refCount ;
100
104
}
101
105
102
- private automaticCleanup ( serverApp : FirebaseServerAppImpl ) : void {
103
- void deleteApp ( serverApp ) ;
106
+ // Invoked by the FinalizationRegistry callback to note that this app should go through its
107
+ // reference counts and delete itself if no reference count remain. The coordinating logic that
108
+ // handles this is in deleteApp(...).
109
+ private automaticCleanup ( ) : void {
110
+ void deleteApp ( this ) ;
104
111
}
105
112
106
113
get settings ( ) : FirebaseServerAppSettings {
You can’t perform that action at this time.
0 commit comments