400
);
401
});
402
403
- // @gate enablePostpone
404
- it('does not fatally error when aborting with a postpone during a prerender', async () => {
405
- let postponedValue;
406
- try {
407
- React.unstable_postpone('aborting with postpone');
408
- } catch (e) {
409
- postponedValue = e;
410
- }
411
-
412
- const controller = new AbortController();
413
- const infinitePromise = new Promise(() => {});
414
- function App() {
415
- React.use(infinitePromise);
416
- return <div>aborted</div>;
417
- }
418
-
419
- const errors = [];
420
- const pendingResult = ReactDOMFizzStatic.prerenderToNodeStream(<App />, {
421
- onError: error => {
422
- errors.push(error);
423
- },
424
- signal: controller.signal,
425
- });
426
- pendingResult.catch(() => {});
427
-
428
- await Promise.resolve();
429
- controller.abort(postponedValue);
430
-
431
- const result = await pendingResult;
432
-
433
- await act(async () => {
434
- result.prelude.pipe(writable);
435
- });
436
- expect(getVisibleChildren(container)).toEqual(undefined);
437
- expect(errors).toEqual([]);
438
- });
439
-
440
- // @gate enablePostpone
441
- it('does not fatally error when aborting with a postpone during a prerender from within', async () => {
442
- let postponedValue;
443
- try {
444
- React.unstable_postpone('aborting with postpone');
445
- } catch (e) {
446
- postponedValue = e;
447
- }
448
-
449
- const controller = new AbortController();
450
- function App() {
451
- controller.abort(postponedValue);
452
- return <div>aborted</div>;
453
- }
454
-
455
- const errors = [];
456
- const result = await ReactDOMFizzStatic.prerenderToNodeStream(<App />, {
457
- onError: error => {
458
- errors.push(error);
459
- },
460
- signal: controller.signal,
461
- });
462
- await act(async () => {
463
- result.prelude.pipe(writable);
464
- });
465
- expect(getVisibleChildren(container)).toEqual(undefined);
466
- expect(errors).toEqual([]);
467
- });
468
-
403
// @gate enableHalt
404
it('will halt a prerender when aborting with an error during a render', async () => {
405
const controller = new AbortController();