Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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 (
<Suspense fallback="Loading...">
<div>{largeContent}</div>
</Suspense>
);
}

let streamedContent = '';
const writable = new (require('stream').Writable)({
write(chunk, encoding, callback) {
streamedContent += chunk.toString();
callback();
},
});

await new Promise(resolve => {
const {pipe} = ReactDOMFizzServer.renderToPipeableStream(<App />, {
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...');
});
});
4 changes: 1 addition & 3 deletions packages/react-server/src/ReactFizzServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down