grpc-js: Fix call ref timer handling #2626
Merged
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.
I think this change fixes the bug described in #2586 (comment).
The purpose of the
callRefTimer
is to hold the process open as long as there are calls that the channel is responsible for tracking because they are queued to either get a config from the resolver, or get a pick from the LB policy. Once a call becomes attached to a connection, that connection takes over tracking it and the responsibility for holding the process open. The generalcallRefTimer
workflow goes like this:Once a resolver update has been received, calls never queue for configs anymore, they get them immediately after being created. And calls only queue for picks once they have a config. So, there is never a case when both queues are in use at the same time. The problem before this change is that if an update comes in from the resolver after the initial resolver update while there are calls in the pick queue, the timer would be unreffed but there would be no calls in the config queue, so nothing would trigger reffing the timer again. The fix is to only unref the timer if there is at least one call in the queue to process. I added the same condition to all call sites for consistency.