From 28e0ebacfdf925b0204a83456e64c98e1696ba21 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 28 May 2026 10:12:21 +0200 Subject: [PATCH 1/2] stream: switch to internal `sleep` binding Signed-off-by: Antoine du Hamel --- lib/internal/streams/fast-utf8-stream.js | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/lib/internal/streams/fast-utf8-stream.js b/lib/internal/streams/fast-utf8-stream.js index cb86f245302620..d3e7b141fcd798 100644 --- a/lib/internal/streams/fast-utf8-stream.js +++ b/lib/internal/streams/fast-utf8-stream.js @@ -6,15 +6,14 @@ const { ArrayPrototypePush, - AtomicsWait, Int32Array, MathMax, - Number, SymbolDispose, } = primordials; const { constructSharedArrayBuffer, + sleep, } = require('internal/util'); const { @@ -50,22 +49,6 @@ const { const BUSY_WRITE_TIMEOUT = 100; const kEmptyBuffer = Buffer.allocUnsafe(0); -const kNil = new Int32Array(constructSharedArrayBuffer(4)); - -function sleep(ms) { - // Also filters out NaN, non-number types, including empty strings, but allows bigints - const valid = ms > 0 && ms < Infinity; - if (valid === false) { - if (typeof ms !== 'number' && typeof ms !== 'bigint') { - throw new ERR_INVALID_ARG_TYPE('ms', ['number', 'bigint'], ms); - } - throw new ERR_INVALID_ARG_VALUE.RangeError('ms', ms, - 'must be a number greater than 0 and less than Infinity'); - } - - AtomicsWait(kNil, 0, 0, Number(ms)); -} - // 16 KB. Don't write more than docker buffer size. // https://github.com/moby/moby/blob/513ec73831269947d38a644c278ce3cac36783b2/daemon/logger/copier.go#L13 const kMaxWrite = 16 * 1024; From c5f908891c736e072e4faa21f39801df62e9db69 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 28 May 2026 10:39:13 +0200 Subject: [PATCH 2/2] fixup! stream: switch to internal `sleep` binding --- lib/internal/streams/fast-utf8-stream.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/internal/streams/fast-utf8-stream.js b/lib/internal/streams/fast-utf8-stream.js index d3e7b141fcd798..68601cf5c388c7 100644 --- a/lib/internal/streams/fast-utf8-stream.js +++ b/lib/internal/streams/fast-utf8-stream.js @@ -6,13 +6,11 @@ const { ArrayPrototypePush, - Int32Array, MathMax, SymbolDispose, } = primordials; const { - constructSharedArrayBuffer, sleep, } = require('internal/util');