Skip to content

Commit 2f39306

Browse files
fix: do not throw DeprecationWarnings for legacy retry behavior (#1551)
1 parent 3efb193 commit 2f39306

File tree

2 files changed

+0
-179
lines changed

2 files changed

+0
-179
lines changed

gax/src/gax.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -333,20 +333,6 @@ export function convertRetryOptions(
333333
// if a user provided retry AND retryRequestOptions at call time, throw an error
334334
// otherwise, convert supported parameters
335335
if (!gaxStreamingRetries) {
336-
if (options.retry) {
337-
warn(
338-
'legacy_streaming_retry_behavior',
339-
'Legacy streaming retry behavior will not honor settings passed at call time or via client configuration. Please set gaxStreamingRetries to true to utilize passed retry settings. gaxStreamingRetries behavior will be set to true by default in future releases.',
340-
'DeprecationWarning'
341-
);
342-
}
343-
if (options.retryRequestOptions) {
344-
warn(
345-
'legacy_streaming_retry_request_behavior',
346-
'Legacy streaming retry behavior will not honor retryRequestOptions passed at call time. Please set gaxStreamingRetries to true to utilize passed retry settings. gaxStreamingRetries behavior will convert retryRequestOptions to retry parameters by default in future releases.',
347-
'DeprecationWarning'
348-
);
349-
}
350336
return options;
351337
}
352338
if (options.retry && options.retryRequestOptions) {

gax/test/unit/streaming.ts

Lines changed: 0 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,6 @@ describe('streaming', () => {
234234
});
235235

236236
it('cancels in the middle', done => {
237-
const warnStub = sinon.stub(warnings, 'warn');
238-
239237
// eslint-disable-next-line @typescript-eslint/no-explicit-any
240238
function schedulePush(s: any, c: number) {
241239
const intervalId = setInterval(() => {
@@ -295,14 +293,6 @@ describe('streaming', () => {
295293
assert.strictEqual(err, cancelError);
296294
done();
297295
});
298-
assert.strictEqual(warnStub.callCount, 1);
299-
assert(
300-
warnStub.calledWith(
301-
'legacy_streaming_retry_behavior',
302-
'Legacy streaming retry behavior will not honor settings passed at call time or via client configuration. Please set gaxStreamingRetries to true to utilize passed retry settings. gaxStreamingRetries behavior will be set to true by default in future releases.',
303-
'DeprecationWarning'
304-
)
305-
);
306296
});
307297

308298
it('emit response when stream received metadata event', done => {
@@ -598,8 +588,6 @@ describe('streaming', () => {
598588
});
599589

600590
it('emit parsed GoogleError', done => {
601-
const warnStub = sinon.stub(warnings, 'warn');
602-
603591
const errorInfoObj = {
604592
reason: 'SERVICE_DISABLED',
605593
domain: 'googleapis.com',
@@ -676,14 +664,6 @@ describe('streaming', () => {
676664
s.on('end', () => {
677665
done();
678666
});
679-
assert.strictEqual(warnStub.callCount, 1);
680-
assert(
681-
warnStub.calledWith(
682-
'legacy_streaming_retry_behavior',
683-
'Legacy streaming retry behavior will not honor settings passed at call time or via client configuration. Please set gaxStreamingRetries to true to utilize passed retry settings. gaxStreamingRetries behavior will be set to true by default in future releases.',
684-
'DeprecationWarning'
685-
)
686-
);
687667
});
688668
it('emit parsed GoogleError when new retries are enabled', done => {
689669
const errorInfoObj = {
@@ -1982,101 +1962,6 @@ describe('warns/errors about server streaming retry behavior when gaxStreamingRe
19821962
sinon.restore();
19831963
});
19841964

1985-
it('throws a warning when retryRequestOptions are passed', done => {
1986-
const warnStub = sinon.stub(warnings, 'warn');
1987-
1988-
// this exists to help resolve createApiCall
1989-
sinon.stub(StreamingApiCaller.prototype, 'call').callsFake(() => {
1990-
done();
1991-
});
1992-
1993-
const spy = sinon.spy((...args: Array<{}>) => {
1994-
assert.strictEqual(args.length, 3);
1995-
const s = new PassThrough({
1996-
objectMode: true,
1997-
});
1998-
return s;
1999-
});
2000-
2001-
const apiCall = createApiCallStreaming(
2002-
spy,
2003-
streaming.StreamType.SERVER_STREAMING,
2004-
false,
2005-
false // ensure we are NOT opted into the new retry behavior
2006-
);
2007-
const passedRetryRequestOptions = {
2008-
objectMode: false,
2009-
retries: 1,
2010-
maxRetryDelay: 70,
2011-
retryDelayMultiplier: 3,
2012-
totalTimeout: 650,
2013-
noResponseRetries: 3,
2014-
currentRetryAttempt: 0,
2015-
shouldRetryFn: function alwaysRetry() {
2016-
return true;
2017-
},
2018-
};
2019-
// make the call with both options passed at call time
2020-
apiCall(
2021-
{},
2022-
{
2023-
retryRequestOptions: passedRetryRequestOptions,
2024-
}
2025-
);
2026-
assert.strictEqual(warnStub.callCount, 1);
2027-
assert(
2028-
warnStub.calledWith(
2029-
'legacy_streaming_retry_request_behavior',
2030-
'Legacy streaming retry behavior will not honor retryRequestOptions passed at call time. Please set gaxStreamingRetries to true to utilize passed retry settings. gaxStreamingRetries behavior will convert retryRequestOptions to retry parameters by default in future releases.',
2031-
'DeprecationWarning'
2032-
)
2033-
);
2034-
});
2035-
it('throws a warning when retry options are passed', done => {
2036-
const warnStub = sinon.stub(warnings, 'warn');
2037-
// this exists to help resolve createApiCall
2038-
sinon.stub(StreamingApiCaller.prototype, 'call').callsFake(() => {
2039-
done();
2040-
});
2041-
2042-
const spy = sinon.spy((...args: Array<{}>) => {
2043-
assert.strictEqual(args.length, 3);
2044-
const s = new PassThrough({
2045-
objectMode: true,
2046-
});
2047-
return s;
2048-
});
2049-
2050-
const apiCall = createApiCallStreaming(
2051-
spy,
2052-
streaming.StreamType.SERVER_STREAMING,
2053-
false,
2054-
false // ensure we are NOT opted into the new retry behavior
2055-
);
2056-
2057-
// make the call with both options passed at call time
2058-
apiCall(
2059-
{},
2060-
{
2061-
retry: gax.createRetryOptions([1], {
2062-
initialRetryDelayMillis: 300,
2063-
retryDelayMultiplier: 1.2,
2064-
maxRetryDelayMillis: 1000,
2065-
rpcTimeoutMultiplier: 1.5,
2066-
maxRpcTimeoutMillis: 3000,
2067-
totalTimeoutMillis: 4500,
2068-
}),
2069-
}
2070-
);
2071-
assert.strictEqual(warnStub.callCount, 1);
2072-
assert(
2073-
warnStub.calledWith(
2074-
'legacy_streaming_retry_behavior',
2075-
'Legacy streaming retry behavior will not honor settings passed at call time or via client configuration. Please set gaxStreamingRetries to true to utilize passed retry settings. gaxStreamingRetries behavior will be set to true by default in future releases.',
2076-
'DeprecationWarning'
2077-
)
2078-
);
2079-
});
20801965
it('throws no warnings when when no retry options are passed', done => {
20811966
const warnStub = sinon.stub(warnings, 'warn');
20821967
// this exists to help resolve createApiCall
@@ -2103,56 +1988,6 @@ describe('warns/errors about server streaming retry behavior when gaxStreamingRe
21031988
apiCall({}, {});
21041989
assert.strictEqual(warnStub.callCount, 0);
21051990
});
2106-
it('throws two warnings when when retry and retryRequestoptions are passed', done => {
2107-
const warnStub = sinon.stub(warnings, 'warn');
2108-
// this exists to help resolve createApiCall
2109-
sinon.stub(StreamingApiCaller.prototype, 'call').callsFake(() => {
2110-
done();
2111-
});
2112-
2113-
const spy = sinon.spy((...args: Array<{}>) => {
2114-
assert.strictEqual(args.length, 3);
2115-
const s = new PassThrough({
2116-
objectMode: true,
2117-
});
2118-
return s;
2119-
});
2120-
2121-
const apiCall = createApiCallStreaming(
2122-
spy,
2123-
streaming.StreamType.SERVER_STREAMING,
2124-
false,
2125-
false // ensure we are NOT opted into the new retry behavior
2126-
);
2127-
const passedRetryRequestOptions = {
2128-
objectMode: false,
2129-
retries: 1,
2130-
maxRetryDelay: 70,
2131-
retryDelayMultiplier: 3,
2132-
totalTimeout: 650,
2133-
noResponseRetries: 3,
2134-
currentRetryAttempt: 0,
2135-
shouldRetryFn: function alwaysRetry() {
2136-
return true;
2137-
},
2138-
};
2139-
// make the call with both retry options passed at call time
2140-
apiCall(
2141-
{},
2142-
{
2143-
retryRequestOptions: passedRetryRequestOptions,
2144-
retry: gax.createRetryOptions([1], {
2145-
initialRetryDelayMillis: 300,
2146-
retryDelayMultiplier: 1.2,
2147-
maxRetryDelayMillis: 1000,
2148-
rpcTimeoutMultiplier: 1.5,
2149-
maxRpcTimeoutMillis: 3000,
2150-
totalTimeoutMillis: 4500,
2151-
}),
2152-
}
2153-
);
2154-
assert.strictEqual(warnStub.callCount, 2);
2155-
});
21561991
});
21571992

21581993
describe('REST streaming apiCall return StreamArrayParser', () => {

0 commit comments

Comments
 (0)