From 9a8e8dfd4ddb69792db6a12434c5489875952de0 Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Wed, 20 Nov 2024 17:25:04 -0800 Subject: [PATCH] throw in the deprecated behavior --- src/js/node/http.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/js/node/http.ts b/src/js/node/http.ts index 9a5936e448..bad9df628a 100644 --- a/src/js/node/http.ts +++ b/src/js/node/http.ts @@ -1808,7 +1808,6 @@ function ServerResponse(req, options) { this[controllerSymbol] = undefined; this[firstWriteSymbol] = undefined; this[deferredSymbol] = undefined; - this[finishedSymbol] = false; this.write = ServerResponse_writeDeprecated; this.end = ServerResponse_finalDeprecated; } @@ -2121,6 +2120,13 @@ const ServerResponse_writeDeprecated = function _write(chunk, encoding, callback if (!$isCallable(callback)) { callback = undefined; } + if (this.destroyed || this.finished) { + if (chunk) { + console.error("???"); + emitErrorNextTickIfErrorListenerNT(this, $ERR_STREAM_WRITE_AFTER_END("Cannot write after end"), callback); + } + return false; + } if (this[firstWriteSymbol] === undefined && !this.headersSent) { this[firstWriteSymbol] = chunk; if (callback) callback(); @@ -2198,8 +2204,10 @@ function ServerResponse_finalDeprecated(chunk, encoding, callback) { callback = undefined; } if (this.destroyed || this.finished) { - if (callback) callback(); - return; + if (chunk) { + emitErrorNextTickIfErrorListenerNT(this, $ERR_STREAM_WRITE_AFTER_END("Cannot write after end"), callback); + } + return false; } const req = this.req;