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) { 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, });