summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/http/http_next.rs5
-rw-r--r--ext/http/lib.rs1
-rw-r--r--ext/node/polyfills/internal_binding/stream_wrap.ts8
3 files changed, 12 insertions, 2 deletions
diff --git a/ext/http/http_next.rs b/ext/http/http_next.rs
index 019054894..e95839005 100644
--- a/ext/http/http_next.rs
+++ b/ext/http/http_next.rs
@@ -1078,6 +1078,11 @@ impl Resource for UpgradeStream {
}
}
+#[op(fast)]
+pub fn op_can_write_vectored(state: &mut OpState, rid: ResourceId) -> bool {
+ state.resource_table.get::<UpgradeStream>(rid).is_ok()
+}
+
#[op]
pub async fn op_raw_write_vectored(
state: Rc<RefCell<OpState>>,
diff --git a/ext/http/lib.rs b/ext/http/lib.rs
index 26cbffd1b..c33c1d15e 100644
--- a/ext/http/lib.rs
+++ b/ext/http/lib.rs
@@ -121,6 +121,7 @@ deno_core::extension!(
http_next::op_http_upgrade_websocket_next,
http_next::op_http_upgrade_raw,
http_next::op_raw_write_vectored,
+ http_next::op_can_write_vectored,
http_next::op_http_try_wait,
http_next::op_http_wait,
],
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) => {