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: Fix client pooling for long-lived listens #614
Conversation
These names suggest that the returned Promise represents a stream that has completed and whose client is suitable to release back into the pool, when in fact, it only represents that the stream has successfully initialized.
Previously _initializeStream returned a Promise that indicated that the stream was "released", i.e. that it was was ready for attaching listeners. #256 Added pooled clients and changed the callers of _initializeStream to reuse this promise such that when it was resolved, the stream could be returned to the pool. This works when listeners are short-lived, but fails when listeners run indefinitely. This change arranges to release the clients back to the pool only after the stream has completed, which allows an arbitrary number of indefinite listens to run without problems.
Codecov Report
@@ Coverage Diff @@
## master #614 +/- ##
==========================================
+ Coverage 61.18% 61.29% +0.11%
==========================================
Files 21 21
Lines 3375 3385 +10
Branches 453 454 +1
==========================================
+ Hits 2065 2075 +10
Misses 1250 1250
Partials 60 60
Continue to review full report at Codecov.
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## master #614 +/- ##
==========================================
+ Coverage 61.18% 61.29% +0.11%
==========================================
Files 21 21
Lines 3375 3385 +10
Branches 453 454 +1
==========================================
+ Hits 2065 2075 +10
Misses 1250 1250
Partials 60 60
Continue to review full report at Codecov.
|
Fixes firebase/firebase-admin-node#499
Previously _initializeStream returned a Promise that indicated that the
stream was "released", i.e. that it was was ready for attaching
listeners.
#256 Added pooled clients and changed the
callers of _initializeStream to reuse this promise such that when it was
resolved, the stream could be returned to the pool. This works when
listeners are short-lived, but fails when listeners run indefinitely.
This change arranges to release the clients back to the pool only after
the stream has completed, which allows an arbitrary number of indefinite
listens to run without problems.
This turns out to be fiendishly difficult to test given the current structure
of the code. A second pass at this that reformulates this as just another
stream that composes with the others would make this easier to understand and
test. For now, this fix unblocks the customers waiting on the referenced issue.