Merge pull request #1286 from murgatroid99/grpc-js_auto_retry_code_check

grpc-js: Only automatically retry picks on known error
This commit is contained in:
Michael Lumish 2020-03-04 10:26:05 -08:00 committed by GitHub
commit 2c40be8884
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 19 deletions

View File

@ -265,29 +265,42 @@ export class ChannelImplementation implements Channel {
callStream callStream
); );
} catch (error) { } catch (error) {
/* An error here indicates that something went wrong with if ((error as NodeJS.ErrnoException).code === 'ERR_HTTP2_GOAWAY_SESSION') {
* the picked subchannel's http2 stream right before we /* An error here indicates that something went wrong with
* tried to start the stream. We are handling a promise * the picked subchannel's http2 stream right before we
* result here, so this is asynchronous with respect to the * tried to start the stream. We are handling a promise
* original tryPick call, so calling it again is not * result here, so this is asynchronous with respect to the
* recursive. We call tryPick immediately instead of * original tryPick call, so calling it again is not
* queueing this pick again because handling the queue is * recursive. We call tryPick immediately instead of
* triggered by state changes, and we want to immediately * queueing this pick again because handling the queue is
* check if the state has already changed since the * triggered by state changes, and we want to immediately
* previous tryPick call. We do this instead of cancelling * check if the state has already changed since the
* the stream because the correct behavior may be * previous tryPick call. We do this instead of cancelling
* re-queueing instead, based on the logic in the rest of * the stream because the correct behavior may be
* tryPick */ * re-queueing instead, based on the logic in the rest of
trace( * tryPick */
LogVerbosity.INFO, trace(
'channel', LogVerbosity.INFO,
'Failed to start call on picked subchannel ' + 'channel',
'Failed to start call on picked subchannel ' +
pickResult.subchannel!.getAddress() + pickResult.subchannel!.getAddress() +
' with error ' + ' with error ' +
(error as Error).message + (error as Error).message +
'. Retrying pick' '. Retrying pick'
); );
this.tryPick(callStream, callMetadata); this.tryPick(callStream, callMetadata);
} else {
trace(
LogVerbosity.INFO,
'channel',
'Failed to start call on picked subchanel ' +
pickResult.subchannel!.getAddress() +
' with error ' +
(error as Error).message +
'. Ending call'
);
callStream.cancelWithStatus(Status.INTERNAL, 'Failed to start HTTP/2 stream');
}
} }
} else { } else {
/* The logic for doing this here is the same as in the catch /* The logic for doing this here is the same as in the catch