Skip to content
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: don't retry server streaming calls if retryCodes is the empty array #1578

Merged
merged 42 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a804c37
get branch in sync with upstream main
leahecole Apr 18, 2023
ecfb2f7
feat: update server streaming retries
leahecole Aug 22, 2023
783e736
Merge branch 'main' into gax4upgrade-2
leahecole Aug 22, 2023
25f1046
rerun npx gts fix
leahecole Aug 23, 2023
78b9e5b
fix two of three failing browser tests
leahecole Aug 23, 2023
f258a1c
Regenerate showcase (#12)
leahecole Aug 24, 2023
038ad48
fix lint
leahecole Aug 24, 2023
5c7fc4e
test: use a custom header for testing headers
alexander-fenster Aug 24, 2023
5a4bd71
rename "newRetry" parameter
leahecole Aug 30, 2023
12bd5d0
remove extend dependency
leahecole Aug 30, 2023
288f3b1
fix lint
leahecole Aug 30, 2023
8a7d5a2
fix issue where underlying errors were swallowed
leahecole Aug 31, 2023
a40172b
resolve some comments
leahecole Sep 5, 2023
ee9261f
replace console logs with our warn module
leahecole Sep 5, 2023
e5e332e
utilize enum
leahecole Sep 5, 2023
1d0d0f7
replace "any" with "GoogleError"
leahecole Sep 5, 2023
6666710
update array checks
leahecole Sep 5, 2023
a2b9cc9
remove debug statement
leahecole Sep 5, 2023
c6cccb9
remove need to typecast
leahecole Sep 5, 2023
62875cc
null coalescing fix
leahecole Sep 6, 2023
a095163
reduce duplication
leahecole Sep 6, 2023
2df47aa
clean up some optional chaining
leahecole Sep 6, 2023
152981e
make error optional
leahecole Sep 7, 2023
18b0d58
Merge branch 'main' of github.com:googleapis/gax-nodejs into gax4upgr…
leahecole Sep 25, 2023
9251c20
WIP: use nullish coalescing and optional chaining for parameter conve…
leahecole Sep 27, 2023
a737798
more nullish coalescing and optional chaining
leahecole Sep 27, 2023
1db7f49
falsiness checks
leahecole Sep 28, 2023
da3d8c3
Request/response type
leahecole Sep 29, 2023
c59005b
Request/response type
leahecole Sep 29, 2023
e09f94f
make createAPIcall nested statements more readable
leahecole Sep 29, 2023
ca8d1f7
retryCodesOrShouldRetryFn
leahecole Oct 2, 2023
deb5328
make retryCodesOrShouldRetryFn less awful
leahecole Oct 2, 2023
823e1d7
fix Sofia's comments
leahecole Oct 4, 2023
4066501
Merge branch 'main' of github.com:googleapis/gax-nodejs into gax4upgr…
leahecole Oct 5, 2023
ad6491d
Merge branch 'main' of github.com:googleapis/gax-nodejs into gax4upgr…
leahecole Oct 31, 2023
2d17563
Retrycodes refactor (#13)
leahecole Nov 10, 2023
3c92036
resolve typescript warnings
leahecole Nov 13, 2023
0d9baff
Merge branch 'main' of github.com:googleapis/gax-nodejs
leahecole Mar 19, 2024
4c44308
fix: dont retry on empty retryCodes server stream
leahecole Mar 27, 2024
0355d5a
Merge branch 'main' into testretries
leahecole Mar 27, 2024
e7d2d22
npm run fix
leahecole Mar 27, 2024
a4d3a14
Merge branch 'main' into testretries
leahecole Mar 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions gax/src/streamingCalls/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,9 @@ export class StreamProxy extends duplexify implements GRPCCallResult {

defaultShouldRetry(error: GoogleError, retry: RetryOptions) {
if (
retry.retryCodes.length > 0 &&
retry.retryCodes.indexOf(error!.code!) < 0
(retry.retryCodes.length > 0 &&
retry.retryCodes.indexOf(error!.code!) < 0) ||
retry.retryCodes.length === 0
) {
return false;
}
Expand Down
54 changes: 54 additions & 0 deletions gax/test/unit/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,60 @@ describe('handles server streaming retries in gax when gaxStreamingRetries is en
}
});
});
it('does not retry when there is no shouldRetryFn and retryCodes is an empty array', done => {
const retrySpy = sinon.spy(streaming.StreamProxy.prototype, 'retry');
const firstError = Object.assign(new GoogleError('UNAVAILABLE'), {
code: 14,
details: 'UNAVAILABLE',
metadata: new Metadata(),
});

const spy = sinon.spy((...args: Array<{}>) => {
assert.strictEqual(args.length, 3);
const s = new PassThrough({
objectMode: true,
});
s.push('hello');
setImmediate(() => {
s.emit('metadata');
});
setImmediate(() => {
s.emit('error', firstError);
});
return s;
});

const apiCall = createApiCallStreaming(
spy,
streaming.StreamType.SERVER_STREAMING,
false,
true
);

const call = apiCall(
{},
{
// pass an empty array for retryCodes
retry: gax.createRetryOptions([], {
initialRetryDelayMillis: 100,
retryDelayMultiplier: 1.2,
maxRetryDelayMillis: 1000,
rpcTimeoutMultiplier: 1.5,
maxRpcTimeoutMillis: 3000,
maxRetries: 2,
}),
}
);

call.on('error', err => {
assert(err instanceof GoogleError);
if (err.code === 14) {
assert.strictEqual(err.code, 14);
assert.strictEqual(retrySpy.callCount, 0);
done();
}
});
});

it('server streaming call retries until exceeding total timeout', done => {
const firstError = Object.assign(new GoogleError('UNAVAILABLE'), {
Expand Down
Loading