Skip to content

Commit 33a3244

Browse files
authored
Remove renderToStaticNodeStream (#28873)
Stacked on #28872 renderToStaticNodeStream was not originally deprecated when renderToNodeStream was deprecated because it did not yet have a clear analog in the modern streaming implementation for SSR. In React 19 we have already removed renderToNodeStream. This change removes renderToStaticNodeStream as well because you can replicate it's semantics using renderToPipeableStream with onAllReady or renderToReadableStream with await stream.allready.
1 parent d329ff9 commit 33a3244

15 files changed

+4
-332
lines changed

packages/react-dom/npm/server.browser.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ if (process.env.NODE_ENV === 'production') {
1212
exports.version = l.version;
1313
exports.renderToString = l.renderToString;
1414
exports.renderToStaticMarkup = l.renderToStaticMarkup;
15-
exports.renderToStaticNodeStream = l.renderToStaticNodeStream;
1615
exports.renderToReadableStream = s.renderToReadableStream;
1716
if (s.resume) {
1817
exports.resume = s.resume;

packages/react-dom/npm/server.bun.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ exports.renderToReadableStream = b.renderToReadableStream;
1515
if (b.resume) {
1616
exports.resume = b.resume;
1717
}
18-
exports.renderToStaticNodeStream = b.renderToStaticNodeStream;
1918
exports.renderToString = l.renderToString;
2019
exports.renderToStaticMarkup = l.renderToStaticMarkup;

packages/react-dom/npm/server.edge.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ if (process.env.NODE_ENV === 'production') {
1212

1313
exports.version = b.version;
1414
exports.renderToReadableStream = b.renderToReadableStream;
15-
exports.renderToStaticNodeStream = b.renderToStaticNodeStream;
1615
exports.renderToString = l.renderToString;
1716
exports.renderToStaticMarkup = l.renderToStaticMarkup;
1817
if (b.resume) {

packages/react-dom/npm/server.node.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ if (process.env.NODE_ENV === 'production') {
1212
exports.version = l.version;
1313
exports.renderToString = l.renderToString;
1414
exports.renderToStaticMarkup = l.renderToStaticMarkup;
15-
exports.renderToStaticNodeStream = l.renderToStaticNodeStream;
1615
exports.renderToPipeableStream = s.renderToPipeableStream;
1716
if (s.resumeToPipeableStream) {
1817
exports.resumeToPipeableStream = s.resumeToPipeableStream;

packages/react-dom/server.browser.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ export function renderToStaticMarkup() {
2323
arguments,
2424
);
2525
}
26-
export function renderToStaticNodeStream() {
27-
return require('./src/server/ReactDOMLegacyServerBrowser').renderToStaticNodeStream.apply(
28-
this,
29-
arguments,
30-
);
31-
}
3226

3327
export function renderToReadableStream() {
3428
return require('./src/server/react-dom-server.browser').renderToReadableStream.apply(

packages/react-dom/server.bun.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ export function renderToReadableStream() {
1818
);
1919
}
2020

21-
export function renderToStaticNodeStream() {
22-
return require('./src/server/react-dom-server.bun').renderToStaticNodeStream.apply(
23-
this,
24-
arguments,
25-
);
26-
}
27-
2821
export function renderToString() {
2922
return require('./src/server/ReactDOMLegacyServerBrowser').renderToString.apply(
3023
this,

packages/react-dom/server.edge.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ export function renderToReadableStream() {
1818
);
1919
}
2020

21-
export function renderToStaticNodeStream() {
22-
return require('./src/server/react-dom-server.edge').renderToStaticNodeStream.apply(
23-
this,
24-
arguments,
25-
);
26-
}
27-
2821
export function renderToString() {
2922
return require('./src/server/ReactDOMLegacyServerBrowser').renderToString.apply(
3023
this,

packages/react-dom/server.node.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ export function renderToStaticMarkup() {
2323
arguments,
2424
);
2525
}
26-
export function renderToStaticNodeStream() {
27-
return require('./src/server/ReactDOMLegacyServerNode').renderToStaticNodeStream.apply(
28-
this,
29-
arguments,
30-
);
31-
}
3226

3327
export function renderToPipeableStream() {
3428
return require('./src/server/react-dom-server.node').renderToPipeableStream.apply(

packages/react-dom/src/__tests__/ReactDOMServerIntegrationNewContext-test.js

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -324,97 +324,6 @@ describe('ReactDOMServerIntegration', () => {
324324
expect(e.textContent).toBe('dark');
325325
});
326326

327-
it('does not pollute parallel node streams', () => {
328-
const LoggedInUser = React.createContext();
329-
330-
const AppWithUser = user => (
331-
<LoggedInUser.Provider value={user}>
332-
<header>
333-
<LoggedInUser.Consumer>{whoAmI => whoAmI}</LoggedInUser.Consumer>
334-
</header>
335-
<footer>
336-
<LoggedInUser.Consumer>{whoAmI => whoAmI}</LoggedInUser.Consumer>
337-
</footer>
338-
</LoggedInUser.Provider>
339-
);
340-
341-
const streamAmy = ReactDOMServer.renderToStaticNodeStream(
342-
AppWithUser('Amy'),
343-
).setEncoding('utf8');
344-
const streamBob = ReactDOMServer.renderToStaticNodeStream(
345-
AppWithUser('Bob'),
346-
).setEncoding('utf8');
347-
348-
// Testing by filling the buffer using internal _read() with a small
349-
// number of bytes to avoid a test case which needs to align to a
350-
// highWaterMark boundary of 2^14 chars.
351-
streamAmy._read(20);
352-
streamBob._read(20);
353-
streamAmy._read(20);
354-
streamBob._read(20);
355-
356-
expect(streamAmy.read()).toBe('<header>Amy</header><footer>Amy</footer>');
357-
expect(streamBob.read()).toBe('<header>Bob</header><footer>Bob</footer>');
358-
});
359-
360-
it('does not pollute parallel node streams when many are used', () => {
361-
const CurrentIndex = React.createContext();
362-
363-
const NthRender = index => (
364-
<CurrentIndex.Provider value={index}>
365-
<header>
366-
<CurrentIndex.Consumer>{idx => idx}</CurrentIndex.Consumer>
367-
</header>
368-
<footer>
369-
<CurrentIndex.Consumer>{idx => idx}</CurrentIndex.Consumer>
370-
</footer>
371-
</CurrentIndex.Provider>
372-
);
373-
374-
const streams = [];
375-
376-
// Test with more than 32 streams to test that growing the thread count
377-
// works properly.
378-
const streamCount = 34;
379-
380-
for (let i = 0; i < streamCount; i++) {
381-
streams[i] = ReactDOMServer.renderToStaticNodeStream(
382-
NthRender(i % 2 === 0 ? 'Expected to be recreated' : i),
383-
).setEncoding('utf8');
384-
}
385-
386-
// Testing by filling the buffer using internal _read() with a small
387-
// number of bytes to avoid a test case which needs to align to a
388-
// highWaterMark boundary of 2^14 chars.
389-
for (let i = 0; i < streamCount; i++) {
390-
streams[i]._read(20);
391-
}
392-
393-
// Early destroy every other stream
394-
for (let i = 0; i < streamCount; i += 2) {
395-
streams[i].destroy();
396-
}
397-
398-
// Recreate those same streams.
399-
for (let i = 0; i < streamCount; i += 2) {
400-
streams[i] = ReactDOMServer.renderToStaticNodeStream(
401-
NthRender(i),
402-
).setEncoding('utf8');
403-
}
404-
405-
// Read a bit from all streams again.
406-
for (let i = 0; i < streamCount; i++) {
407-
streams[i]._read(20);
408-
}
409-
410-
// Assert that all stream rendered the expected output.
411-
for (let i = 0; i < streamCount; i++) {
412-
expect(streams[i].read()).toBe(
413-
'<header>' + i + '</header><footer>' + i + '</footer>',
414-
);
415-
}
416-
});
417-
418327
it('does not pollute sync renders after an error', () => {
419328
const LoggedInUser = React.createContext('default');
420329
const Crash = () => {

packages/react-dom/src/__tests__/ReactServerRendering-test.js

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -577,73 +577,6 @@ describe('ReactDOMServer', () => {
577577
});
578578
});
579579

580-
describe('renderToStaticNodeStream', () => {
581-
it('should generate simple markup', () => {
582-
const SuccessfulElement = React.createElement(() => <img />);
583-
expect(() => {
584-
const response =
585-
ReactDOMServer.renderToStaticNodeStream(SuccessfulElement);
586-
expect(response.read().toString()).toMatch(new RegExp('<img' + '/>'));
587-
}).toErrorDev(
588-
'ReactDOMServer.renderToStaticNodeStream() is deprecated and will be removed in an upcomingrelease of React',
589-
{withoutStack: true},
590-
);
591-
});
592-
593-
it('should handle errors correctly', () => {
594-
const FailingElement = React.createElement(() => {
595-
throw new Error('An Error');
596-
});
597-
598-
let response;
599-
expect(() => {
600-
response = ReactDOMServer.renderToStaticNodeStream(FailingElement);
601-
}).toErrorDev(
602-
'ReactDOMServer.renderToStaticNodeStream() is deprecated and will be removed in an upcomingrelease of React',
603-
{withoutStack: true},
604-
);
605-
return new Promise(resolve => {
606-
response.once('error', () => {
607-
resolve();
608-
});
609-
expect(response.read()).toBeNull();
610-
});
611-
});
612-
613-
it('should omit text and suspense placeholders', async () => {
614-
let resolve = null;
615-
const promise = new Promise(res => {
616-
resolve = () => {
617-
resolved = true;
618-
res();
619-
};
620-
});
621-
let resolved = false;
622-
function Suspender() {
623-
if (resolved) {
624-
return 'resolved';
625-
}
626-
throw promise;
627-
}
628-
629-
let response;
630-
expect(() => {
631-
response = ReactDOMServer.renderToStaticNodeStream(
632-
<div>
633-
<React.Suspense fallback={'fallback'}>
634-
<Suspender />
635-
</React.Suspense>
636-
</div>,
637-
);
638-
}).toErrorDev(
639-
'ReactDOMServer.renderToStaticNodeStream() is deprecated and will be removed in an upcomingrelease of React',
640-
{withoutStack: true},
641-
);
642-
await resolve();
643-
expect(response.read().toString()).toEqual('<div>resolved</div>');
644-
});
645-
});
646-
647580
it('warns with a no-op when an async setState is triggered', () => {
648581
class Foo extends React.Component {
649582
UNSAFE_componentWillMount() {

0 commit comments

Comments
 (0)