diff options
| author | Satya Rohith <me@satyarohith.com> | 2024-05-16 17:42:01 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-16 17:42:01 +0530 |
| commit | 7893ab9f0bb406081723ce80829d3ad6303da162 (patch) | |
| tree | 1ad05bb4fc1c25ffbcc3089259c44f676cb96a7e /ext/node/polyfills | |
| parent | 00e6d41a9d86c3c1a2e8807461bab127e52f0a10 (diff) | |
fix(ext/node): fix grpc error_handling example (#23755)
gRPC depends only on the END_STREAM flag to emit "trailers" event which
is responsible to propagate the errors correctly. This patch uses
Body::is_end_stream() to determine if a stream will end and set the
END_STREAM flag.
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'ext/node/polyfills')
| -rw-r--r-- | ext/node/polyfills/http2.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/ext/node/polyfills/http2.ts b/ext/node/polyfills/http2.ts index b9d9f4b06..59756dd0f 100644 --- a/ext/node/polyfills/http2.ts +++ b/ext/node/polyfills/http2.ts @@ -822,7 +822,7 @@ export class ClientHttp2Stream extends Duplex { session[kDenoClientRid], this.#rid, ); - const response = await op_http2_client_get_response( + const [response, endStream] = await op_http2_client_get_response( this.#rid, ); debugHttp2(">>> after get response", response); @@ -831,7 +831,13 @@ export class ClientHttp2Stream extends Duplex { ...Object.fromEntries(response.headers), }; debugHttp2(">>> emitting response", headers); - this.emit("response", headers, 0); + this.emit( + "response", + headers, + endStream + ? constants.NGHTTP2_FLAG_END_STREAM + : constants.NGHTTP2_FLAG_NONE, + ); this[kDenoResponse] = response; this.emit("ready"); })(); |
