Closed alexluke closed 7 months ago
Hi @alexluke, thank you for your report.
Could you please try following patch if it works for you:
--- a/src/nodejs/unit-http/http_server.js
+++ b/src/nodejs/unit-http/http_server.js
@@ -160,6 +160,10 @@ ServerResponse.prototype._removeHeader =
this.headers_len -= name_len + Buffer.byteLength(value + "", 'latin1');
};
+ServerResponse.prototype.flushHeaders = function flushHeaders() {
+ this._sendHeaders();
+}
+
ServerResponse.prototype.sendDate = function sendDate() {
throw new Error("Not supported");
};
--- a/src/nodejs/unit-http/http_server.js +++ b/src/nodejs/unit-http/http_server.js @@ -160,6 +160,10 @@ ServerResponse.prototype._removeHeader = this.headers_len -= name_len + Buffer.byteLength(value + "", 'latin1'); }; +ServerResponse.prototype.flushHeaders = function flushHeaders() { + this._sendHeaders(); +}
Any reason there's no trailing ;
here?
No, it was just my inattention. Thank you for noticing! Additionally, I've moved this code slightly higher to reduce the confusion between private and public methods ordering for headers:
diff --git a/src/nodejs/unit-http/http_server.js b/src/nodejs/unit-http/http_server.js
--- a/src/nodejs/unit-http/http_server.js
+++ b/src/nodejs/unit-http/http_server.js
@@ -138,6 +138,10 @@ ServerResponse.prototype.removeHeader =
}
};
+ServerResponse.prototype.flushHeaders = function flushHeaders() {
+ this._sendHeaders();
+};
+
ServerResponse.prototype._removeHeader = function _removeHeader(lc_name) {
let entry = this.headers[lc_name];
let name_len = Buffer.byteLength(entry[0] + "", 'latin1');
I can't honestly say whether this is correct or not, but it looks simple enough, so assuming it works... consider it...
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
We have a nextjs 14.0.2 app that is built in standalone mode. We're using nginx unit for TLS termination.
When responding to a request, the following error is thrown.
This appears to be because the
flushHeaders
method doesn't exist on theServerResponse
under nginx unit. The app runs fine when using node's own http module.https://github.com/vercel/next.js/blob/v14.0.2/packages/next/src/server/pipe-readable.ts#L48
https://nodejs.org/api/http.html#responseflushheaders
Please let me know what other detail would be helpful.