mirror of https://github.com/grpc/grpc-node.git
grpc-js: Different handling for errors when starting streams
This commit is contained in:
parent
c5a6e5506e
commit
f0e19f1d0d
|
@ -142,7 +142,9 @@ export class ChannelImplementation implements Channel {
|
||||||
) {
|
) {
|
||||||
/* The global boolean parameter to getSubchannelPool has the inverse meaning to what
|
/* The global boolean parameter to getSubchannelPool has the inverse meaning to what
|
||||||
* the grpc.use_local_subchannel_pool channel option means. */
|
* the grpc.use_local_subchannel_pool channel option means. */
|
||||||
this.subchannelPool = getSubchannelPool((options['grpc.use_local_subchannel_pool'] ?? 0) === 0);
|
this.subchannelPool = getSubchannelPool(
|
||||||
|
(options['grpc.use_local_subchannel_pool'] ?? 0) === 0
|
||||||
|
);
|
||||||
const channelControlHelper: ChannelControlHelper = {
|
const channelControlHelper: ChannelControlHelper = {
|
||||||
createSubchannel: (
|
createSubchannel: (
|
||||||
subchannelAddress: string,
|
subchannelAddress: string,
|
||||||
|
@ -234,16 +236,25 @@ export class ChannelImplementation implements Channel {
|
||||||
callStream
|
callStream
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
callStream.cancelWithStatus(
|
/* An error here indicates thaat something when wrong with
|
||||||
Status.UNAVAILABLE,
|
* the picked subchannel's http2 stream right before we
|
||||||
'Failed to start call on picked subchannel'
|
* tried to start the stream. We are handling a promise
|
||||||
);
|
* result here, so this asynchronous with respect to the
|
||||||
|
* original tryPick call, so calling it again is not
|
||||||
|
* recursive. We call tryPick immediately instead of
|
||||||
|
* queueing this pick again because handling the queue is
|
||||||
|
* triggered by state changes, and we want to immediately
|
||||||
|
* check if the state has already changed since the
|
||||||
|
* previous tryPick call. We do this instead of cancelling
|
||||||
|
* the stream because the correct behavior may be
|
||||||
|
* re-queueing instead, based on the logic in the rest of
|
||||||
|
* tryPick */
|
||||||
|
this.tryPick(callStream, callMetadata);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
callStream.cancelWithStatus(
|
/* The logic for doing this here is the same as in the catch
|
||||||
Status.UNAVAILABLE,
|
* block above */
|
||||||
'Connection dropped while starting call'
|
this.tryPick(callStream, callMetadata);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(error: Error & { code: number }) => {
|
(error: Error & { code: number }) => {
|
||||||
|
|
Loading…
Reference in New Issue