From e450c6b7cb23be95862d48ef047490490391c9d9 Mon Sep 17 00:00:00 2001 From: Satya Rohith Date: Thu, 23 May 2024 23:01:20 +0530 Subject: fix(ext/node): return cancelled flag in get_response_body_chunk op (#23962) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The flag lets us exit from read loop without throwing an error when the stream is cancelled. This fixes gRPC cancellation example. Co-authored-by: Bartek IwaƄczuk --- ext/node/polyfills/http2.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'ext/node/polyfills') diff --git a/ext/node/polyfills/http2.ts b/ext/node/polyfills/http2.ts index 59756dd0f..c47e54d1b 100644 --- a/ext/node/polyfills/http2.ts +++ b/ext/node/polyfills/http2.ts @@ -1007,9 +1007,14 @@ export class ClientHttp2Stream extends Duplex { debugHttp2(">>> read"); (async () => { - const [chunk, finished] = await op_http2_client_get_response_body_chunk( - this[kDenoResponse].bodyRid, - ); + const [chunk, finished, cancelled] = + await op_http2_client_get_response_body_chunk( + this[kDenoResponse].bodyRid, + ); + + if (cancelled) { + return; + } debugHttp2(">>> chunk", chunk, finished, this[kDenoResponse].bodyRid); if (chunk === null) { -- cgit v1.2.3