94
ReactDOM = require('react-dom');
95
ReactDOMClient = require('react-dom/client');
96
ReactDOMFizzServer = require('react-dom/server');
97
- if (__EXPERIMENTAL__) {
98
- ReactDOMFizzStatic = require('react-dom/static');
99
- }
97
+ ReactDOMFizzStatic = require('react-dom/static');
98
Stream = require('stream');
99
Suspense = React.Suspense;
100
use = React.use;
10782
// Instead we assert that we never emitted the fallback of the Suspense boundary around the body.
10783
expect(streamedContent).not.toContain(randomTag);
10784
});
10785
+
10786
+ it('should be able to Suspend after aborting in the same component without hanging the render', async () => {
10787
+ const controller = new AbortController();
10788
+
10789
+ const promise1 = new Promise(() => {});
10790
+ function AbortAndSuspend() {
10791
+ controller.abort('boom');
10792
+ return React.use(promise1);
10793
+ }
10794
+
10795
+ function App() {
10796
+ return (
10797
+ <html>
10798
+ <body>
10799
+ <Suspense fallback="loading...">
10800
+ {/*
10801
+ The particular code path that was problematic required the Suspend to happen in renderNode
10802
+ rather than retryRenderTask so we render the aborting function inside a host component
10803
+ intentionally here
10804
+ */}
10805
+ <div>
10806
+ <AbortAndSuspend />
10807
+ </div>
10808
+ </Suspense>
10809
+ </body>
10810
+ </html>
10811
+ );
10812
+ }
10813
+
10814
+ const errors = [];
10815
+ await act(async () => {
10816
+ const result = await ReactDOMFizzStatic.prerenderToNodeStream(<App />, {
10817
+ signal: controller.signal,
10818
+ onError(e) {
10819
+ errors.push(e);
10820
+ },
10821
+ });
10822
+
10823
+ result.prelude.pipe(writable);
10824
+ });
10825
+
10826
+ expect(errors).toEqual(['boom']);
10827
+
10828
+ expect(getVisibleChildren(document)).toEqual(
10829
+ <html>
10830
+ <head />
10831
+ <body>loading...</body>
10832
+ </html>,
10833
+ );
10834
+ });
10835
});