Repository navigation
Conversation
…nt converter (opennextjs#1255) - Protect statusCode in OpenNextNodeResponse from being overwritten after headersSent (fixes Next.js resetting statusCode to originalStatus after sendRenderResult) - Omit body and bodyEncoding for NULL_BODY_STATUSES (304, 204) in aws-cloudfront converter to comply with CloudFront Lambda@Edge specifications - Set proper statusDescription using http.STATUS_CODES instead of hardcoding "OK" - Add unit tests for OpenNextNodeResponse and aws-cloudfront converter Fixes opennextjs#1255
🦋 Changeset detectedLatest commit: 837b6a1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
conico974
reviewed
Sep 27, 2026
…CE_NON_EMPTY_RESPONSE=true
commit: |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1255
When a request is made with a matching
If-None-Matchheader:send-payload.js) detects the match, setsres.statusCode = 304, and ends the stream with 0 chunks.next/dist/server/base-server.js(pipeImplline 1119), Next.js resetsres.statusCode = originalStatus(which isundefined).304 Not Modifiedhas already been sent over the wire. However, in OpenNext's non-streaming/buffered mode (e.g., Lambda@Edge),convertResreadsres.statusCodeonly afterprocessRequestresolves, defaulting to200.status: 200with an empty body"", causing browsers to render a blank page.304or204must not containbodyorbodyEncoding(doing so triggers CloudFront 502 errors).Changes
packages/open-next/src/http/openNextResponse.ts: EncapsulatestatusCodewith getter/setter to prevent mutation onceheadersSent === true, matching standard Node.js HTTP response immutability semantics.packages/open-next/src/overrides/converters/aws-cloudfront.ts:bodyandbodyEncodingforNULL_BODY_STATUSES(304, 204, etc.) per CloudFront requirements.statusDescriptionusinghttp.STATUS_CODES[result.statusCode]instead of hardcoded"OK".openNextResponse.test.tsto assertstatusCodepreservation afterres.end()andflushHeaders().aws-cloudfront.test.tsfor 304, 204, and 200 responses.