googleapis / gax-nodejs

Google API Extensions for Node.js
Apache License 2.0
113 stars 83 forks source link

fix: Prepare reset counter to 0 pr #1602

Closed danieljbruce closed 1 month ago

danieljbruce commented 1 month ago

Source code changes

A handler for data is added along with a line of code that sets the retry counter to 0 when data is received. This ensures that the max retries limit is only reached if enough consecutive retriable errors are encountered without any data being received between those errors. This is being introduced to match current nodejs-bigtable retry behaviour where a counter is reset that interacts with the maxRetries parameters for custom retries.

Test changes

A test is added that emits 4 retryable errors from a server while also emitting data between each error. Since max retries is set in this test to 2 then the test ensures that the retry count is actually being reset because the test only passes if none of the retriable errors result in the max retries limit being reached.