fix: Do not allow gaxOptions to be modified downstream #1379
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.
Currently, #1372 has a failing test that produces an error that says
Uncaught Error: Only one of retry or retryRequestOptions may be set
. This code change allows that test to pass on thegcf-owl-bot
PR branch.Here is what currently happens:
The failing test uses a mock server that aborts the stream simulating a network error. This causes the client to retry. However, on the first call the client makes,
options.gaxOptions
gets passed down the stack atnodejs-bigtable/src/table.ts
Line 906 in 8cc17aa
options.gaxOptions
is defined having settings that matchhttps://github.com/googleapis/nodejs-bigtable/blob/8cc17aa2acb2540b4c2b233c4245021815a7b030/src/v2/bigtable_client_config.json#L12-L20.
. On the second call,options.gaxOptions
is passed down the stack with theretry
parameter defined this time and with the retryRequestOptions parameter attached atnodejs-bigtable/src/index.ts
Line 859 in 8cc17aa
Uncaught Error: Only one of retry or retryRequestOptions may be set
.What this fix does:
With this fix a copy of
options.gaxOptions
is passed down the call stack instead ofoptions.gaxOptions
itself. This means when the client retries,options.gaxOptions
does not contain theretry
parameter in the createReadStream function as this parameter is normally filled out much further down the stack. This means the errorUncaught Error: Only one of retry or retryRequestOptions may be set
is not thrown.Additional effects:
For retries, this means
options.gaxOptions?.retry?.backoffSettings
will beundefined
atnodejs-bigtable/src/table.ts
Lines 960 to 962 in 8cc17aa
DEFAULT_BACKOFF_SETTINGS
if backoff settings are not provided by the user. This is exactly what we want and is also the intent of the current code.