mirror of
https://github.com/grpc/grpc-node.git
synced 2025-12-08 18:23:54 +00:00
Merge pull request #2073 from murgatroid99/grpc-js_write_error_handling
grpc-js: Avoid surfacing errors without gRPC error codes
This commit is contained in:
commit
76d03e7f47
@ -839,7 +839,16 @@ export class Http2CallStream implements Call {
|
||||
message,
|
||||
flags: context.flags,
|
||||
};
|
||||
const cb: WriteCallback = context.callback ?? (() => {});
|
||||
const cb: WriteCallback = (error?: Error | null) => {
|
||||
let code: Status = Status.UNAVAILABLE;
|
||||
if ((error as NodeJS.ErrnoException)?.code === 'ERR_STREAM_WRITE_AFTER_END') {
|
||||
code = Status.INTERNAL;
|
||||
}
|
||||
if (error) {
|
||||
this.cancelWithStatus(code, `Write error: ${error.message}`);
|
||||
}
|
||||
context.callback?.();
|
||||
};
|
||||
this.isWriteFilterPending = true;
|
||||
this.filterStack.sendMessage(Promise.resolve(writeObj)).then((message) => {
|
||||
this.isWriteFilterPending = false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user