Disable enablePostpone flag in experimental (#31042)

I don't think we're ready to land this yet since we're using it to run
other experiments and our tests. I'm opening this PR to indicate intent
to disable and to ensure tests in other combinations still work. Such as
enableHalt without enablePostpone. I think we'll also need to rewrite
some tests that depend on enablePostpone to preserve some coverage.

The conclusion after this experiment is that try/catch around these are
too likely to block these signals and consider them error. Throwing
works for Hooks and `use()` because the lint rule can ensure that
they're not wrapped in try/catch. Throwing in arbitrary functions not
quite ecosystem compatible. It's also why there's `use()` and not just
throwing a Promise. This might also affect the Catch proposal.

The "prerender" for SSR that's supporting "Partial Prerendering" is
still there. This just disables the `React.postpone()` API for creating
the holes.
This commit is contained in:
Sebastian Markbåge authored and GitHub committed 2025-11-04 23:23:25 -05:00
1 parent 986323f8c6
commit c308cb5905
7 files changed
+1 -75

No files matched your search

@@ -400,72 +400,6 @@ describe('ReactDOMFizzStatic', () => {
);
});
// @gate enablePostpone
it('does not fatally error when aborting with a postpone during a prerender', async () => {
let postponedValue;
try {
React.unstable_postpone('aborting with postpone');
} catch (e) {
postponedValue = e;
}
const controller = new AbortController();
const infinitePromise = new Promise(() => {});
function App() {
React.use(infinitePromise);
return <div>aborted</div>;
}
const errors = [];
const pendingResult = ReactDOMFizzStatic.prerenderToNodeStream(<App />, {
onError: error => {
errors.push(error);
},
signal: controller.signal,
});
pendingResult.catch(() => {});
await Promise.resolve();
controller.abort(postponedValue);
const result = await pendingResult;
await act(async () => {
result.prelude.pipe(writable);
});
expect(getVisibleChildren(container)).toEqual(undefined);
expect(errors).toEqual([]);
});
// @gate enablePostpone
it('does not fatally error when aborting with a postpone during a prerender from within', async () => {
let postponedValue;
try {
React.unstable_postpone('aborting with postpone');
} catch (e) {
postponedValue = e;
}
const controller = new AbortController();
function App() {
controller.abort(postponedValue);
return <div>aborted</div>;
}
const errors = [];
const result = await ReactDOMFizzStatic.prerenderToNodeStream(<App />, {
onError: error => {
errors.push(error);
},
signal: controller.signal,
});
await act(async () => {
result.prelude.pipe(writable);
});
expect(getVisibleChildren(container)).toEqual(undefined);
expect(errors).toEqual([]);
});
// @gate enableHalt
it('will halt a prerender when aborting with an error during a render', async () => {
const controller = new AbortController();
@@ -30,7 +30,6 @@ export {
cacheSignal,
startTransition,
Activity,
unstable_postpone,
unstable_getCacheForType,
unstable_SuspenseList,
ViewTransition,
-1
View File
@@ -31,7 +31,6 @@ export {
startTransition,
Activity,
Activity as unstable_Activity,
unstable_postpone,
unstable_getCacheForType,
unstable_SuspenseList,
ViewTransition,
-2
View File
@@ -34,7 +34,6 @@ import {lazy} from './ReactLazy';
import {forwardRef} from './ReactForwardRef';
import {memo} from './ReactMemo';
import {cache, cacheSignal} from './ReactCacheClient';
import {postpone} from './ReactPostpone';
import {
getCacheForType,
useCallback,
@@ -84,7 +83,6 @@ export {
memo,
cache,
cacheSignal,
postpone as unstable_postpone,
useCallback,
useContext,
useEffect,
@@ -38,7 +38,6 @@ import {lazy} from './ReactLazy';
import {memo} from './ReactMemo';
import {cache, cacheSignal} from './ReactCacheServer';
import {startTransition} from './ReactStartTransition';
import {postpone} from './ReactPostpone';
import {captureOwnerStack} from './ReactOwnerStack';
import version from 'shared/ReactVersion';
@@ -76,7 +75,6 @@ export {
cacheSignal,
startTransition,
getCacheForType as unstable_getCacheForType,
postpone as unstable_postpone,
useId,
useCallback,
useDebugValue,
@@ -38,7 +38,6 @@ import {lazy} from './ReactLazy';
import {memo} from './ReactMemo';
import {cache, cacheSignal} from './ReactCacheServer';
import {startTransition} from './ReactStartTransition';
import {postpone} from './ReactPostpone';
import version from 'shared/ReactVersion';
const Children = {
@@ -75,7 +74,6 @@ export {
cacheSignal,
startTransition,
getCacheForType as unstable_getCacheForType,
postpone as unstable_postpone,
useId,
useCallback,
useDebugValue,
+1 -1
View File
@@ -80,7 +80,7 @@ export const enableAsyncIterableChildren = __EXPERIMENTAL__;
export const enableTaint = __EXPERIMENTAL__;
export const enablePostpone = __EXPERIMENTAL__;
export const enablePostpone: boolean = false; // Probably won't ship in this form.
export const enableHalt: boolean = true;