Skip to content

Commit

Permalink
Fix Node.js v16 error responses on HTTP1.1
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Stamm <ts@timostamm.de>
  • Loading branch information
timostamm committed Sep 3, 2024
1 parent e442279 commit 2b82475
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/conformance-express.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [21.1.0, 20.9.0, 18.16.0]
node-version: [21.1.0, 20.9.0, 18.16.0, 16.20.0]
name: "Node.js ${{ matrix.node-version }}"
timeout-minutes: 10
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/conformance-fastify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [21.1.0, 20.9.0, 18.16.0]
node-version: [21.1.0, 20.9.0, 18.16.0, 16.20.0]
name: "Node.js ${{ matrix.node-version }}"
timeout-minutes: 10
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/conformance-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [21.1.0, 20.9.0, 18.16.0]
node-version: [21.1.0, 20.9.0, 18.16.0, 16.20.0]
side: [client, server]
name: "Node.js ${{ matrix.node-version }} ${{ matrix.side }}"
timeout-minutes: 10
Expand Down
11 changes: 10 additions & 1 deletion packages/connect-node/src/node-universal-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,16 @@ export async function universalResponseToNodeResponse(
async function* asyncIterableFromNodeServerRequest(
request: NodeServerRequest,
): AsyncIterable<Uint8Array> {
for await (const chunk of request) {
const it = request.iterator({
// Node.js v16 closes request and response when this option isn't disabled.
// When one of our handlers receives invalid data (such as an unexpected
// compression flag in a streaming request), we're unable to write the error
// response.
// Later major versions have a more sensible behavior - we can revert this
// workaround once we stop supporting v16.
destroyOnReturn: false,
});
for await (const chunk of it) {
yield chunk;
}
}
Expand Down

0 comments on commit 2b82475

Please sign in to comment.