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
Expand Up @@ -6710,7 +6710,6 @@ describe('ReactDOMFizzServer', () => {
},
);

// @gate enableHalt
it('can resume a prerender that was aborted', async () => {
const promise = new Promise(r => {});

Expand Down
6 changes: 1 addition & 5 deletions packages/react-dom/src/__tests__/ReactDOMFizzStatic-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ describe('ReactDOMFizzStatic', () => {

const result = await promise;

expect(result.postponed).toBe(
gate(flags => flags.enableHalt) ? null : undefined,
);
expect(result.postponed).toBe(null);

await act(async () => {
result.prelude.pipe(writable);
Expand Down Expand Up @@ -362,7 +360,6 @@ describe('ReactDOMFizzStatic', () => {
);
});

// @gate enableHalt
it('will halt a prerender when aborting with an error during a render', async () => {
const controller = new AbortController();
function App() {
Expand All @@ -384,7 +381,6 @@ describe('ReactDOMFizzStatic', () => {
expect(getVisibleChildren(container)).toEqual(undefined);
});

// @gate enableHalt
it('will halt a prerender when aborting with an error in a microtask', async () => {
const errors = [];

Expand Down
101 changes: 7 additions & 94 deletions packages/react-dom/src/__tests__/ReactDOMFizzStaticBrowser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,40 +309,6 @@ describe('ReactDOMFizzStaticBrowser', () => {
expect(errors).toEqual(['This operation was aborted']);
});

// @gate !enableHalt
it('should reject if aborting before the shell is complete and enableHalt is disabled', async () => {
const errors = [];
const controller = new AbortController();
const promise = serverAct(() =>
ReactDOMFizzStatic.prerender(
<div>
<InfiniteSuspend />
</div>,
{
signal: controller.signal,
onError(x) {
errors.push(x.message);
},
},
),
);

await jest.runAllTimers();

const theReason = new Error('aborted for reasons');
controller.abort(theReason);

let caughtError = null;
try {
await promise;
} catch (error) {
caughtError = error;
}
expect(caughtError).toBe(theReason);
expect(errors).toEqual(['aborted for reasons']);
});

// @gate enableHalt
it('should resolve an empty prelude if aborting before the shell is complete', async () => {
const errors = [];
const controller = new AbortController();
Expand Down Expand Up @@ -403,59 +369,12 @@ describe('ReactDOMFizzStaticBrowser', () => {
),
);

if (gate(flags => flags.enableHalt)) {
const {prelude} = await streamPromise;
const content = await readContent(prelude);
expect(errors).toEqual(['This operation was aborted']);
expect(content).toBe('');
} else {
let caughtError = null;
try {
await streamPromise;
} catch (error) {
caughtError = error;
}
expect(caughtError.message).toBe('This operation was aborted');
expect(errors).toEqual(['This operation was aborted']);
}
});

// @gate !enableHalt
it('should reject if passing an already aborted signal and enableHalt is disabled', async () => {
const errors = [];
const controller = new AbortController();
const theReason = new Error('aborted for reasons');
controller.abort(theReason);

const promise = serverAct(() =>
ReactDOMFizzStatic.prerender(
<div>
<Suspense fallback={<div>Loading</div>}>
<InfiniteSuspend />
</Suspense>
</div>,
{
signal: controller.signal,
onError(x) {
errors.push(x.message);
},
},
),
);

// Technically we could still continue rendering the shell but currently the
// semantics mean that we also abort any pending CPU work.
let caughtError = null;
try {
await promise;
} catch (error) {
caughtError = error;
}
expect(caughtError).toBe(theReason);
expect(errors).toEqual(['aborted for reasons']);
const {prelude} = await streamPromise;
const content = await readContent(prelude);
expect(errors).toEqual(['This operation was aborted']);
expect(content).toBe('');
});

// @gate enableHalt
it('should resolve an empty prelude if passing an already aborted signal', async () => {
const errors = [];
const controller = new AbortController();
Expand Down Expand Up @@ -593,16 +512,13 @@ describe('ReactDOMFizzStaticBrowser', () => {
onError,
}),
);
expect(prerendered.postponed).toBe(
gate(flags => flags.enableHalt) ? null : undefined,
);
expect(prerendered.postponed).toBe(null);
expect(errors).toEqual(['bad onHeaders']);

await readIntoContainer(prerendered.prelude);
expect(getVisibleChildren(container)).toEqual(<div>hello</div>);
});

// @gate enableHalt
it('can resume render of a prerender', async () => {
const errors = [];

Expand Down Expand Up @@ -689,7 +605,6 @@ describe('ReactDOMFizzStaticBrowser', () => {
expect(getVisibleChildren(container)).toEqual(<div>Hello</div>);
});

// @gate enableHalt
it('can prerender a preamble', async () => {
const errors = [];

Expand Down Expand Up @@ -850,7 +765,6 @@ describe('ReactDOMFizzStaticBrowser', () => {
expect(errors).toEqual(['boom']);
});

// @gate enableHalt
it('will render fallback Document when erroring a boundary above the body', async () => {
let isPrerendering = true;
const promise = new Promise(() => {});
Expand Down Expand Up @@ -927,7 +841,6 @@ describe('ReactDOMFizzStaticBrowser', () => {
);
});

// @gate enableHalt
it('can omit a preamble with an empty shell if no preamble is ready when prerendering finishes', async () => {
const errors = [];

Expand Down Expand Up @@ -1027,7 +940,7 @@ describe('ReactDOMFizzStaticBrowser', () => {
);
});

// @gate enableHalt && enableSuspenseList
// @gate enableSuspenseList
it('can resume a partially prerendered SuspenseList', async () => {
const errors = [];

Expand Down Expand Up @@ -1112,7 +1025,7 @@ describe('ReactDOMFizzStaticBrowser', () => {
);
});

// @gate enableHalt && enableOptimisticKey
// @gate enableOptimisticKey
it('can resume an optimistic keyed slot', async () => {
const errors = [];

Expand Down
99 changes: 4 additions & 95 deletions packages/react-dom/src/__tests__/ReactDOMFizzStaticNode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ describe('ReactDOMFizzStaticNode', () => {
}
}

// @gate enableHalt
it('should call prerenderToNodeStream', async () => {
const result = await ReactDOMFizzStatic.prerenderToNodeStream(
<div>hello world</div>,
Expand All @@ -65,14 +64,12 @@ describe('ReactDOMFizzStaticNode', () => {
expect(prelude).toMatchInlineSnapshot(`"<div>hello world</div>"`);
});

// @gate enableHalt
it('should suppport web streams', async () => {
const result = await ReactDOMFizzStatic.prerender(<div>hello world</div>);
const prelude = await readContentWeb(result.prelude);
expect(prelude).toMatchInlineSnapshot(`"<div>hello world</div>"`);
});

// @gate enableHalt
it('should emit DOCTYPE at the root of the document', async () => {
const result = await ReactDOMFizzStatic.prerenderToNodeStream(
<html>
Expand All @@ -91,7 +88,6 @@ describe('ReactDOMFizzStaticNode', () => {
}
});

// @gate enableHalt
it('should emit bootstrap script src at the end', async () => {
const result = await ReactDOMFizzStatic.prerenderToNodeStream(
<div>hello world</div>,
Expand All @@ -107,7 +103,6 @@ describe('ReactDOMFizzStaticNode', () => {
);
});

// @gate enableHalt
it('emits all HTML as one unit', async () => {
let hasLoaded = false;
let resolve;
Expand Down Expand Up @@ -137,7 +132,6 @@ describe('ReactDOMFizzStaticNode', () => {
expect(prelude).toMatchInlineSnapshot(`"<div><!--$-->Done<!--/$--></div>"`);
});

// @gate enableHalt
it('should reject the promise when an error is thrown at the root', async () => {
const reportedErrors = [];
let caughtError = null;
Expand All @@ -159,7 +153,6 @@ describe('ReactDOMFizzStaticNode', () => {
expect(reportedErrors).toEqual([theError]);
});

// @gate enableHalt
it('should reject the promise when an error is thrown inside a fallback', async () => {
const reportedErrors = [];
let caughtError = null;
Expand All @@ -183,7 +176,6 @@ describe('ReactDOMFizzStaticNode', () => {
expect(reportedErrors).toEqual([theError]);
});

// @gate enableHalt
it('should not error the stream when an error is thrown inside suspense boundary', async () => {
const reportedErrors = [];
const result = await ReactDOMFizzStatic.prerenderToNodeStream(
Expand All @@ -204,7 +196,6 @@ describe('ReactDOMFizzStaticNode', () => {
expect(reportedErrors).toEqual([theError]);
});

// @gate enableHalt
it('should be able to complete by aborting even if the promise never resolves', async () => {
const errors = [];
const controller = new AbortController();
Expand Down Expand Up @@ -234,39 +225,6 @@ describe('ReactDOMFizzStaticNode', () => {
expect(errors).toEqual(['This operation was aborted']);
});

// @gate enableHalt
// @gate !enableHalt
it('should reject if aborting before the shell is complete and enableHalt is disabled', async () => {
const errors = [];
const controller = new AbortController();
const promise = ReactDOMFizzStatic.prerenderToNodeStream(
<div>
<InfiniteSuspend />
</div>,
{
signal: controller.signal,
onError(x) {
errors.push(x.message);
},
},
);

await jest.runAllTimers();

const theReason = new Error('aborted for reasons');
controller.abort(theReason);

let caughtError = null;
try {
await promise;
} catch (error) {
caughtError = error;
}
expect(caughtError).toBe(theReason);
expect(errors).toEqual(['aborted for reasons']);
});

// @gate enableHalt
it('should resolve an empty shell if aborting before the shell is complete', async () => {
const errors = [];
const controller = new AbortController();
Expand Down Expand Up @@ -300,7 +258,6 @@ describe('ReactDOMFizzStaticNode', () => {
expect(content).toBe('');
});

// @gate enableHalt
it('should be able to abort before something suspends', async () => {
const errors = [];
const controller = new AbortController();
Expand All @@ -324,58 +281,12 @@ describe('ReactDOMFizzStaticNode', () => {
},
);

if (gate(flags => flags.enableHalt)) {
const {prelude} = await streamPromise;
const content = await readContent(prelude);
expect(errors).toEqual(['This operation was aborted']);
expect(content).toBe('');
} else {
let caughtError = null;
try {
await streamPromise;
} catch (error) {
caughtError = error;
}
expect(caughtError.message).toBe('This operation was aborted');
expect(errors).toEqual(['This operation was aborted']);
}
});

// @gate enableHalt
// @gate !enableHalt
it('should reject if passing an already aborted signal and enableHalt is disabled', async () => {
const errors = [];
const controller = new AbortController();
const theReason = new Error('aborted for reasons');
controller.abort(theReason);

const promise = ReactDOMFizzStatic.prerenderToNodeStream(
<div>
<Suspense fallback={<div>Loading</div>}>
<InfiniteSuspend />
</Suspense>
</div>,
{
signal: controller.signal,
onError(x) {
errors.push(x.message);
},
},
);

// Technically we could still continue rendering the shell but currently the
// semantics mean that we also abort any pending CPU work.
let caughtError = null;
try {
await promise;
} catch (error) {
caughtError = error;
}
expect(caughtError).toBe(theReason);
expect(errors).toEqual(['aborted for reasons']);
const {prelude} = await streamPromise;
const content = await readContent(prelude);
expect(errors).toEqual(['This operation was aborted']);
expect(content).toBe('');
});

// @gate enableHalt
it('should resolve with an empty prelude if passing an already aborted signal', async () => {
const errors = [];
const controller = new AbortController();
Expand Down Expand Up @@ -412,7 +323,6 @@ describe('ReactDOMFizzStaticNode', () => {
expect(content).toBe('');
});

// @gate enableHalt
it('supports custom abort reasons with a string', async () => {
const promise = new Promise(r => {});
function Wait() {
Expand Down Expand Up @@ -454,7 +364,6 @@ describe('ReactDOMFizzStaticNode', () => {
expect(errors).toEqual(['foobar', 'foobar']);
});

// @gate enableHalt
it('supports custom abort reasons with an Error', async () => {
const promise = new Promise(r => {});
function Wait() {
Expand Down
Loading
Loading