From 51b3534b3d3833667e8c029564bebf319b0d2596 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Wed, 19 Jul 2023 03:04:26 +0530 Subject: fix(ext/node): check if resource can be used with write_vectored (#19868) Fixes https://github.com/denoland/deno/issues/19766 Fixes https://github.com/denoland/deno/issues/19846 --- ext/node/polyfills/internal_binding/stream_wrap.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'ext/node/polyfills') diff --git a/ext/node/polyfills/internal_binding/stream_wrap.ts b/ext/node/polyfills/internal_binding/stream_wrap.ts index 95f60fe95..528dd7c3f 100644 --- a/ext/node/polyfills/internal_binding/stream_wrap.ts +++ b/ext/node/polyfills/internal_binding/stream_wrap.ts @@ -199,14 +199,18 @@ export class LibuvStreamWrap extends HandleWrap { allBuffers: boolean, ): number { const supportsWritev = this.provider === providerType.TCPSERVERWRAP; + const rid = this[kStreamBaseField]!.rid; // Fast case optimization: two chunks, and all buffers. - if (chunks.length === 2 && allBuffers && supportsWritev) { + if ( + chunks.length === 2 && allBuffers && supportsWritev && + ops.op_can_write_vectored(rid) + ) { // String chunks. if (typeof chunks[0] === "string") chunks[0] = Buffer.from(chunks[0]); if (typeof chunks[1] === "string") chunks[1] = Buffer.from(chunks[1]); ops.op_raw_write_vectored( - this[kStreamBaseField]!.rid, + rid, chunks[0], chunks[1], ).then((nwritten) => { -- cgit v1.2.3