Skip to content

Commit 9a5996a

Browse files
authored
[flags] Cleanup enableHalt (facebook#35708)
1 parent 1c66ac7 commit 9a5996a

20 files changed

Lines changed: 61 additions & 311 deletions

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6710,7 +6710,6 @@ describe('ReactDOMFizzServer', () => {
67106710
},
67116711
);
67126712

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

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,7 @@ describe('ReactDOMFizzStatic', () => {
230230

231231
const result = await promise;
232232

233-
expect(result.postponed).toBe(
234-
gate(flags => flags.enableHalt) ? null : undefined,
235-
);
233+
expect(result.postponed).toBe(null);
236234

237235
await act(async () => {
238236
result.prelude.pipe(writable);
@@ -362,7 +360,6 @@ describe('ReactDOMFizzStatic', () => {
362360
);
363361
});
364362

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

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

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

Lines changed: 7 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -309,40 +309,6 @@ describe('ReactDOMFizzStaticBrowser', () => {
309309
expect(errors).toEqual(['This operation was aborted']);
310310
});
311311

312-
// @gate !enableHalt
313-
it('should reject if aborting before the shell is complete and enableHalt is disabled', async () => {
314-
const errors = [];
315-
const controller = new AbortController();
316-
const promise = serverAct(() =>
317-
ReactDOMFizzStatic.prerender(
318-
<div>
319-
<InfiniteSuspend />
320-
</div>,
321-
{
322-
signal: controller.signal,
323-
onError(x) {
324-
errors.push(x.message);
325-
},
326-
},
327-
),
328-
);
329-
330-
await jest.runAllTimers();
331-
332-
const theReason = new Error('aborted for reasons');
333-
controller.abort(theReason);
334-
335-
let caughtError = null;
336-
try {
337-
await promise;
338-
} catch (error) {
339-
caughtError = error;
340-
}
341-
expect(caughtError).toBe(theReason);
342-
expect(errors).toEqual(['aborted for reasons']);
343-
});
344-
345-
// @gate enableHalt
346312
it('should resolve an empty prelude if aborting before the shell is complete', async () => {
347313
const errors = [];
348314
const controller = new AbortController();
@@ -403,59 +369,12 @@ describe('ReactDOMFizzStaticBrowser', () => {
403369
),
404370
);
405371

406-
if (gate(flags => flags.enableHalt)) {
407-
const {prelude} = await streamPromise;
408-
const content = await readContent(prelude);
409-
expect(errors).toEqual(['This operation was aborted']);
410-
expect(content).toBe('');
411-
} else {
412-
let caughtError = null;
413-
try {
414-
await streamPromise;
415-
} catch (error) {
416-
caughtError = error;
417-
}
418-
expect(caughtError.message).toBe('This operation was aborted');
419-
expect(errors).toEqual(['This operation was aborted']);
420-
}
421-
});
422-
423-
// @gate !enableHalt
424-
it('should reject if passing an already aborted signal and enableHalt is disabled', async () => {
425-
const errors = [];
426-
const controller = new AbortController();
427-
const theReason = new Error('aborted for reasons');
428-
controller.abort(theReason);
429-
430-
const promise = serverAct(() =>
431-
ReactDOMFizzStatic.prerender(
432-
<div>
433-
<Suspense fallback={<div>Loading</div>}>
434-
<InfiniteSuspend />
435-
</Suspense>
436-
</div>,
437-
{
438-
signal: controller.signal,
439-
onError(x) {
440-
errors.push(x.message);
441-
},
442-
},
443-
),
444-
);
445-
446-
// Technically we could still continue rendering the shell but currently the
447-
// semantics mean that we also abort any pending CPU work.
448-
let caughtError = null;
449-
try {
450-
await promise;
451-
} catch (error) {
452-
caughtError = error;
453-
}
454-
expect(caughtError).toBe(theReason);
455-
expect(errors).toEqual(['aborted for reasons']);
372+
const {prelude} = await streamPromise;
373+
const content = await readContent(prelude);
374+
expect(errors).toEqual(['This operation was aborted']);
375+
expect(content).toBe('');
456376
});
457377

458-
// @gate enableHalt
459378
it('should resolve an empty prelude if passing an already aborted signal', async () => {
460379
const errors = [];
461380
const controller = new AbortController();
@@ -593,16 +512,13 @@ describe('ReactDOMFizzStaticBrowser', () => {
593512
onError,
594513
}),
595514
);
596-
expect(prerendered.postponed).toBe(
597-
gate(flags => flags.enableHalt) ? null : undefined,
598-
);
515+
expect(prerendered.postponed).toBe(null);
599516
expect(errors).toEqual(['bad onHeaders']);
600517

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

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

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

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

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

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

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

@@ -1027,7 +940,7 @@ describe('ReactDOMFizzStaticBrowser', () => {
1027940
);
1028941
});
1029942

1030-
// @gate enableHalt && enableSuspenseList
943+
// @gate enableSuspenseList
1031944
it('can resume a partially prerendered SuspenseList', async () => {
1032945
const errors = [];
1033946

@@ -1112,7 +1025,7 @@ describe('ReactDOMFizzStaticBrowser', () => {
11121025
);
11131026
});
11141027

1115-
// @gate enableHalt && enableOptimisticKey
1028+
// @gate enableOptimisticKey
11161029
it('can resume an optimistic keyed slot', async () => {
11171030
const errors = [];
11181031

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

Lines changed: 4 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ describe('ReactDOMFizzStaticNode', () => {
5656
}
5757
}
5858

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

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

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

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

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

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

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

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

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

237-
// @gate enableHalt
238-
// @gate !enableHalt
239-
it('should reject if aborting before the shell is complete and enableHalt is disabled', async () => {
240-
const errors = [];
241-
const controller = new AbortController();
242-
const promise = ReactDOMFizzStatic.prerenderToNodeStream(
243-
<div>
244-
<InfiniteSuspend />
245-
</div>,
246-
{
247-
signal: controller.signal,
248-
onError(x) {
249-
errors.push(x.message);
250-
},
251-
},
252-
);
253-
254-
await jest.runAllTimers();
255-
256-
const theReason = new Error('aborted for reasons');
257-
controller.abort(theReason);
258-
259-
let caughtError = null;
260-
try {
261-
await promise;
262-
} catch (error) {
263-
caughtError = error;
264-
}
265-
expect(caughtError).toBe(theReason);
266-
expect(errors).toEqual(['aborted for reasons']);
267-
});
268-
269-
// @gate enableHalt
270228
it('should resolve an empty shell if aborting before the shell is complete', async () => {
271229
const errors = [];
272230
const controller = new AbortController();
@@ -300,7 +258,6 @@ describe('ReactDOMFizzStaticNode', () => {
300258
expect(content).toBe('');
301259
});
302260

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

327-
if (gate(flags => flags.enableHalt)) {
328-
const {prelude} = await streamPromise;
329-
const content = await readContent(prelude);
330-
expect(errors).toEqual(['This operation was aborted']);
331-
expect(content).toBe('');
332-
} else {
333-
let caughtError = null;
334-
try {
335-
await streamPromise;
336-
} catch (error) {
337-
caughtError = error;
338-
}
339-
expect(caughtError.message).toBe('This operation was aborted');
340-
expect(errors).toEqual(['This operation was aborted']);
341-
}
342-
});
343-
344-
// @gate enableHalt
345-
// @gate !enableHalt
346-
it('should reject if passing an already aborted signal and enableHalt is disabled', async () => {
347-
const errors = [];
348-
const controller = new AbortController();
349-
const theReason = new Error('aborted for reasons');
350-
controller.abort(theReason);
351-
352-
const promise = ReactDOMFizzStatic.prerenderToNodeStream(
353-
<div>
354-
<Suspense fallback={<div>Loading</div>}>
355-
<InfiniteSuspend />
356-
</Suspense>
357-
</div>,
358-
{
359-
signal: controller.signal,
360-
onError(x) {
361-
errors.push(x.message);
362-
},
363-
},
364-
);
365-
366-
// Technically we could still continue rendering the shell but currently the
367-
// semantics mean that we also abort any pending CPU work.
368-
let caughtError = null;
369-
try {
370-
await promise;
371-
} catch (error) {
372-
caughtError = error;
373-
}
374-
expect(caughtError).toBe(theReason);
375-
expect(errors).toEqual(['aborted for reasons']);
284+
const {prelude} = await streamPromise;
285+
const content = await readContent(prelude);
286+
expect(errors).toEqual(['This operation was aborted']);
287+
expect(content).toBe('');
376288
});
377289

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

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

457-
// @gate enableHalt
458367
it('supports custom abort reasons with an Error', async () => {
459368
const promise = new Promise(r => {});
460369
function Wait() {

0 commit comments

Comments
 (0)