From 837c870ff4eef49a6d03071d0a3547ab67bc91f7 Mon Sep 17 00:00:00 2001 From: Gasman <90539473+MarybethGasman@users.noreply.github.com> Date: Tue, 7 Nov 2023 07:51:14 +0800 Subject: fix(node/http): socket.setTimeout (#20930) Fixes #20923 --- cli/tests/unit_node/http_test.ts | 1 + ext/node/polyfills/http.ts | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/cli/tests/unit_node/http_test.ts b/cli/tests/unit_node/http_test.ts index 825815ae6..ed52ccf13 100644 --- a/cli/tests/unit_node/http_test.ts +++ b/cli/tests/unit_node/http_test.ts @@ -355,6 +355,7 @@ Deno.test("[node/http] send request with non-chunked body", async () => { assert(socket.readable); socket.setKeepAlive(); socket.destroy(); + socket.setTimeout(100); }); req.write("hello "); req.write("world"); diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index ae670d5f0..78bd7cb07 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -8,6 +8,7 @@ const core = globalThis.__bootstrap.core; import { TextEncoder } from "ext:deno_web/08_text_encoding.js"; import { type Deferred, deferred } from "ext:deno_node/_util/async.ts"; +import { setTimeout } from "ext:deno_web/02_timers.js"; import { _normalizeArgs, // createConnection, @@ -289,6 +290,10 @@ class FakeSocket extends EventEmitter { end() {} destroy() {} + + setTimeout(callback, timeout = 0, ...args) { + setTimeout(callback, timeout, args); + } } /** ClientRequest represents the http(s) request from the client */ -- cgit v1.2.3