refactor: encapsulate content type within RenderResult (#81861)
### Problem The PPR boundary sentinel was being incorrectly added to responses due to flawed content type logic in `sendRenderResult`. The original conditional logic had complex fallbacks that caused the sentinel to be added when it shouldn't be: ```javascript // BEFORE: Incorrect logic - sentinel added to wrong response types if ( process.env.__NEXT_TEST_MODE && minimalMode && isRoutePPREnabled && //❌ This logic was inverted and unreliable body.contentType !== RSC_CONTENT_TYPE_HEADER && !isRSCRequest ) { body.unshift(createPPRBoundarySentinel()) } ``` The problem was that `body.contentType` was inconsistently determined through external logic in `sendRenderResult`, causing the sentinel to appear in responses that shouldn't have it. ### Solution By moving content type into `RenderResult` constructor, the sentinel logic now correctly identifies HTML responses: ```javascript // AFTER: Correct logic - sentinel only added to HTML responses if ( process.env.__NEXT_TEST_MODE && minimalMode && isRoutePPREnabled && body.contentType === HTML_CONTENT_TYPE_HEADER //✅ Reliable content type check ) { body.unshift(createPPRBoundarySentinel()) } ``` ### Key Changes - **Fixed sentinel logic**: PPR boundary sentinel now only appears in HTML responses where it belongs - **Reliable content type**: Content type is determined at RenderResult creation, not through fallback logic - **Consistent API**: Removed redundant `type` parameter that was causing the confusion This ensures PPR test assertions work correctly by only adding the boundary sentinel to the appropriate response types.
Showing
Please
register
or
sign in
to comment