From 63b516bb504fd85c8430350de5566a0ec8627b9c Mon Sep 17 00:00:00 2001 From: ThierryMT Date: Mon, 27 Oct 2025 15:32:41 +0000 Subject: [PATCH 1/2] http: fix drain event with cork/uncork in ServerResponse When using cork() and uncork() with ServerResponse, the drain event was not reliably emitted after uncorking. This occurred because the uncork() method did not check if a drain was pending (kNeedDrain flag) after flushing the chunked buffer. This fix ensures that when uncork() successfully flushes buffered data and a drain was needed, the drain event is emitted immediately. Fixes: #60432 --- lib/_http_outgoing.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 24aae1caca69d3..7799e62c62c48f 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -287,7 +287,7 @@ OutgoingMessage.prototype.uncork = function uncork() { callbacks.push(buf[n + 2]); } } - this._send(crlf_buf, null, callbacks.length ? (err) => { + const ret = this._send(crlf_buf, null, callbacks.length ? (err) => { for (const callback of callbacks) { callback(err); } @@ -295,6 +295,12 @@ OutgoingMessage.prototype.uncork = function uncork() { this[kChunkedBuffer].length = 0; this[kChunkedLength] = 0; + + // If we successfully flushed and had pending drain, emit it + if (ret && this[kNeedDrain]) { + this[kNeedDrain] = false; + this.emit('drain'); + } }; OutgoingMessage.prototype.setTimeout = function setTimeout(msecs, callback) { From 4134b1090eaf22084292d14a96366119837daaa9 Mon Sep 17 00:00:00 2001 From: ThierryMT Date: Mon, 27 Oct 2025 15:54:51 +0000 Subject: [PATCH 2/2] module: fix EISDIR error with Windows drive-letter-only paths When Windows long paths with \\?\ prefixes are processed during module resolution, the path can sometimes be reduced to just a drive letter (e.g., 'C:'), which causes fs.realpathSync to fail with EISDIR. This adds validation in toRealPath() to detect drive-letter-only paths and append a backslash to make them valid before calling realpathSync. Note: This addresses the immediate symptom. The root cause of why paths are being reduced to drive letters needs further investigation. Fixes: #60435 --- lib/internal/modules/helpers.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/internal/modules/helpers.js b/lib/internal/modules/helpers.js index e2cdc0c5bba74b..258eff11e7b1f0 100644 --- a/lib/internal/modules/helpers.js +++ b/lib/internal/modules/helpers.js @@ -59,6 +59,12 @@ const realpathCache = new SafeMap(); * @returns {string} */ function toRealPath(requestPath) { + // On Windows, ensure the path is valid before calling realpathSync + // to avoid EISDIR errors with malformed paths like 'C:' (drive letter only) + if (process.platform === 'win32' && requestPath.length === 2 && requestPath[1] === ':') { + // If we have just a drive letter, add trailing backslash to make it valid + requestPath += '\\'; + } return fs.realpathSync(requestPath, { [internalFS.realpathCacheKey]: realpathCache, });