Repository: facebook/react
Pull request: [Fizz][Legacy] use static markup mode for renderToStaticNodeStream

Since it was first implemented renderToStaticNodeStream never correctly set the renderer state to mark the output as static markup which means it was functionally the same as renderToNodeStream. This change fixes this oversight. While we are removing renderToNodeStream in a future version we never did deprecate the static version of this API because it has no immediate analog in the modern APIs.


Changed files:
filename: packages/react-dom/src/__tests__/ReactServerRendering-test.js
patch: @@ -609,6 +609,41 @@ describe('ReactDOMServer', () => {
         expect(response.read()).toBeNull();
       });
     });
+
+    it('should refer users to new apis when using suspense', async () => {
+      let resolve = null;
+      const promise = new Promise(res => {
+        resolve = () => {
+          resolved = true;
+          res();
+        };
+      });
+      let resolved = false;
+      function Suspender() {
+        if (resolved) {
+          return 'resolved';
+        }
+        throw promise;
+      }
+
+      let response;
+      expect(() => {
+        response = ReactDOMServer.renderToNodeStream(
+          <div>
+            <React.Suspense fallback={'fallback'}>
+              <Suspender />
+            </React.Suspense>
+          </div>,
+        );
+      }).toErrorDev(
+        'renderToNodeStream is deprecated. Use renderToPipeableStream instead.',
+        {withoutStack: true},
+      );
+      await resolve();
+      expect(response.read().toString()).toEqual(
+        '<div><!--$-->resolved<!-- --><!--/$--></div>',
+      );
+    });
   });
 
   describe('renderToStaticNodeStream', () => {
@@ -632,7 +667,7 @@ describe('ReactDOMServer', () => {
       });
     });
 
-    it('should refer users to new apis when using suspense', async () => {
+    it('should omit text and suspense placeholders', async () => {
       let resolve = null;
       const promise = new Promise(res => {
         resolve = () => {
@@ -648,23 +683,15 @@ describe('ReactDOMServer', () => {
         throw promise;
       }
 
-      let response;
-      expect(() => {
-        response = ReactDOMServer.renderToNodeStream(
-          <div>
-            <React.Suspense fallback={'fallback'}>
-              <Suspender />
-            </React.Suspense>
-          </div>,
-        );
-      }).toErrorDev(
-        'renderToNodeStream is deprecated. Use renderToPipeableStream instead.',
-        {withoutStack: true},
+      const response = ReactDOMServer.renderToStaticNodeStream(
+        <div>
+          <React.Suspense fallback={'fallback'}>
+            <Suspender />
+          </React.Suspense>
+        </div>,
       );
       await resolve();
-      expect(response.read().toString()).toEqual(
-        '<div><!--$-->resolved<!-- --><!--/$--></div>',
-      );
+      expect(response.read().toString()).toEqual('<div>resolved</div>');
     });
   });
 

filename: packages/react-dom/src/server/ReactDOMLegacyServerNodeStream.js
patch: @@ -78,7 +78,7 @@ function renderToNodeStreamImpl(
   const request = createRequest(
     children,
     resumableState,
-    createRenderState(resumableState, false),
+    createRenderState(resumableState, generateStaticMarkup),
     createRootFormatContext(),
     Infinity,
     onError,