Skip to content

Commit c308cb5

Browse files
authored
Disable enablePostpone flag in experimental (facebook#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.
1 parent 986323f commit c308cb5

File tree

7 files changed

+1
-75
lines changed

7 files changed

+1
-75
lines changed

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

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -400,72 +400,6 @@ describe('ReactDOMFizzStatic', () => {
400400
);
401401
});
402402

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-
469403
// @gate enableHalt
470404
it('will halt a prerender when aborting with an error during a render', async () => {
471405
const controller = new AbortController();

packages/react/index.experimental.development.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export {
3030
cacheSignal,
3131
startTransition,
3232
Activity,
33-
unstable_postpone,
3433
unstable_getCacheForType,
3534
unstable_SuspenseList,
3635
ViewTransition,

packages/react/index.experimental.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export {
3131
startTransition,
3232
Activity,
3333
Activity as unstable_Activity,
34-
unstable_postpone,
3534
unstable_getCacheForType,
3635
unstable_SuspenseList,
3736
ViewTransition,

packages/react/src/ReactClient.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import {lazy} from './ReactLazy';
3434
import {forwardRef} from './ReactForwardRef';
3535
import {memo} from './ReactMemo';
3636
import {cache, cacheSignal} from './ReactCacheClient';
37-
import {postpone} from './ReactPostpone';
3837
import {
3938
getCacheForType,
4039
useCallback,
@@ -84,7 +83,6 @@ export {
8483
memo,
8584
cache,
8685
cacheSignal,
87-
postpone as unstable_postpone,
8886
useCallback,
8987
useContext,
9088
useEffect,

packages/react/src/ReactServer.experimental.development.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import {lazy} from './ReactLazy';
3838
import {memo} from './ReactMemo';
3939
import {cache, cacheSignal} from './ReactCacheServer';
4040
import {startTransition} from './ReactStartTransition';
41-
import {postpone} from './ReactPostpone';
4241
import {captureOwnerStack} from './ReactOwnerStack';
4342
import version from 'shared/ReactVersion';
4443

@@ -76,7 +75,6 @@ export {
7675
cacheSignal,
7776
startTransition,
7877
getCacheForType as unstable_getCacheForType,
79-
postpone as unstable_postpone,
8078
useId,
8179
useCallback,
8280
useDebugValue,

packages/react/src/ReactServer.experimental.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import {lazy} from './ReactLazy';
3838
import {memo} from './ReactMemo';
3939
import {cache, cacheSignal} from './ReactCacheServer';
4040
import {startTransition} from './ReactStartTransition';
41-
import {postpone} from './ReactPostpone';
4241
import version from 'shared/ReactVersion';
4342

4443
const Children = {
@@ -75,7 +74,6 @@ export {
7574
cacheSignal,
7675
startTransition,
7776
getCacheForType as unstable_getCacheForType,
78-
postpone as unstable_postpone,
7977
useId,
8078
useCallback,
8179
useDebugValue,

packages/shared/ReactFeatureFlags.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const enableAsyncIterableChildren = __EXPERIMENTAL__;
8080

8181
export const enableTaint = __EXPERIMENTAL__;
8282

83-
export const enablePostpone = __EXPERIMENTAL__;
83+
export const enablePostpone: boolean = false; // Probably won't ship in this form.
8484

8585
export const enableHalt: boolean = true;
8686

0 commit comments

Comments
 (0)