diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzServerNoScript-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzServerNoScript-test.js new file mode 100644 index 00000000000..128fe648350 --- /dev/null +++ b/packages/react-dom/src/__tests__/ReactDOMFizzServerNoScript-test.js @@ -0,0 +1,62 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @emails react-core + * @jest-environment ./scripts/jest/ReactDOMServerIntegrationEnvironment + */ + +'use strict'; + +let React; +let ReactDOMFizzServer; +let Suspense; + +describe('ReactDOMFizzServerNoScript', () => { + beforeEach(() => { + jest.resetModules(); + React = require('react'); + Suspense = React.Suspense; + ReactDOMFizzServer = require('react-dom/server'); + }); + + it('renders large content inline for no-JS support (size-based outlining disabled)', async () => { + // Generate content larger than progressiveChunkSize (100) + const largeContent = 'A'.repeat(2000); + + function App() { + return ( + +
{largeContent}
+
+ ); + } + + let streamedContent = ''; + const writable = new (require('stream').Writable)({ + write(chunk, encoding, callback) { + streamedContent += chunk.toString(); + callback(); + }, + }); + + await new Promise(resolve => { + const {pipe} = ReactDOMFizzServer.renderToPipeableStream(, { + progressiveChunkSize: 100, + onAllReady() { + pipe(writable); + resolve(); + }, + }); + }); + + // Verify content is present in the initial stream (No-JS user sees it) + expect(streamedContent).toContain(largeContent); + + // Verify fallback is NOT present (because it was inlined, so no pending state) + // Note: If it WAS outlined, we would see "Loading..." + expect(streamedContent).not.toContain('Loading...'); + }); +}); diff --git a/packages/react-server/src/ReactFizzServer.js b/packages/react-server/src/ReactFizzServer.js index 920e368674d..ccbfd713dee 100644 --- a/packages/react-server/src/ReactFizzServer.js +++ b/packages/react-server/src/ReactFizzServer.js @@ -5603,9 +5603,7 @@ function flushSegment( // blocked on something later in the stream anyway. !flushingPartialBoundaries && isEligibleForOutlining(request, boundary) && - (flushedByteSize + boundary.byteSize > request.progressiveChunkSize || - hasSuspenseyContent(boundary.contentState) || - boundary.defer) + (hasSuspenseyContent(boundary.contentState) || boundary.defer) ) { // Inlining this boundary would make the current sequence being written too large // and block the parent for too long. Instead, it will be emitted separately so that we