FirebaseServerAppImpl: guard use of FinalizationRegistry based on its availability. #8335
+14
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Discussion
The code had already guarded use of the
FinalizationRegstiry
during the initialization ofFirebaseServerApp
ininitializeServerApp
if thereleaseOnDeref
configuration parameter was defined. This gating was to provide functionality in older node versions. However, there was other code that would errantly attempt to allocate aFinalizationRegstiry
inFirebaseServerAppImpl
regardless of the existence ofreleaseOnDeref
field, and this caused issues in some edge environments.This change fixes that issue.
Testing
I had tested this previously using Node v14.14.0, which is the release version previous to the reported addition of the FinalizationRegistry, and our code had worked. However, it appears that 14.14.0 actually includes the FinalizationRegistry, so my tests completed successfully when they shouldn't have.
I was able to reproduce this problem in Node 14.0.0, and that's the version I used to test this fix.
API Changes
N/A.