-
Notifications
You must be signed in to change notification settings - Fork 896
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
[ServerApp] RefCount FirebaseServerApps #8000
[ServerApp] RefCount FirebaseServerApps #8000
Conversation
And tests to boot.
|
@@ -235,32 +235,37 @@ export function initializeServerApp( | |||
throw ERROR_FACTORY.create(AppError.INVALID_SERVER_APP_ENVIRONMENT); | |||
} | |||
|
|||
if (_serverAppConfig.automaticDataCollectionEnabled === undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous detection of the reusable FirebaseServerApps wasn't taking the automaticDataCollectionEnabled
field into account. We need to explicitly set this to false
if the optional value is not defined, so that it aligns with future FirebaseServerApp
instances that define automaticDataCollectionEnabled
as explicitly false
.
// TODO: | ||
// 1: Register a new reference to finalization registry. | ||
// 2: Incrememnt reference count. | ||
(existingApp as FirebaseServerAppImpl).incRefCount( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removed TODO comment of Register a new reference to finalization registry.
is handled within incRefCount
which, actually thinking about it, handles both of these TODOs.
@@ -362,16 +367,20 @@ export function getApps(): FirebaseApp[] { | |||
* @public | |||
*/ | |||
export async function deleteApp(app: FirebaseApp): Promise<void> { | |||
let foundApp = false; | |||
let cleanupProviders = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed this variable to make it better reflect why the code below is executed (on new line 383).
Size Report 1Affected Products
Test Logs |
Size Analysis Report 1Affected Products
Test Logs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty thorough, nice work.
Discussion
Update the
FirebaseServerApp
creation to return the same object if an existing object exists with the same configuration. However, thedeleteOnDeref
field is ignored when detecting duplicate apps, since that object reference could vary across multiple SSR rendering passes.The hope is that a
FirebaseServerApp
instance awaiting deletion from a thedeleteOnDeref
feature maybe be reused if another SSR pass occurs in rapid succession, there by speeding up the SSR code.Testing
Updated tests to ensure that
FirebaseServerApps
are being deleted properly.Added new tests to track reference counting.
API Changes
N/A.