[Flight] Revert Emit Infinite Promise as a Halted Row (#30746) (#30748)
This reverts commit 52c9c43735d0d5ebb9cd5e2a47c174cb5a5a1713. Just kidding. We realized we probably don't want to do the halted row thing after all.
Sebastian Markbåge committed
Aug 19, 2024 at 16:34 UTC
0fa9476b9b9b7e284fb6ebe7e1c46a6a6ae85f27
3 files changed
+14
-7
packages/react-client/src/ReactFlightClient.js
+9
-2
@@ -46,6 +46,7 @@ import {
46
enableRefAsProp,
47
enableFlightReadableStream,
48
enableOwnerStacks,
49
+ enableHalt,
50
} from 'shared/ReactFeatureFlags';
51
52
import {
@@ -1193,6 +1194,10 @@ function parseModelString(
1194
}
1195
case '@': {
1196
// Promise
1197
+ if (value.length === 2) {
1198
+ // Infinite promise that never resolves.
1199
+ return new Promise(() => {});
1200
+ }
1201
const id = parseInt(value.slice(2), 16);
1202
const chunk = getChunk(response, id);
1203
return chunk;
@@ -2633,8 +2638,10 @@ function processFullStringRow(
2638
}
2639
// Fallthrough
2640
case 35 /* "#" */: {
2636
- resolveBlocked(response, id);
2637
- return;
2641
+ if (enableHalt) {
2642
+ resolveBlocked(response, id);
2643
+ return;
2644
+ }
2645
}
2646
// Fallthrough
2647
default: /* """ "{" "[" "t" "f" "n" "0" - "9" */ {
packages/react-client/src/__tests__/ReactFlight-test.js
-1
@@ -3026,7 +3026,6 @@ describe('ReactFlight', () => {
3026
3027
const promise = mockConsoleLog.mock.calls[0][1].promise;
3028
expect(promise).toBeInstanceOf(Promise);
3029
- expect(promise.status).toBe('blocked');
3029
3030
expect(ownerStacks).toEqual(['\n in App (at **)']);
3031
});
packages/react-server/src/ReactFlightServer.js
+5
-4
@@ -1817,6 +1817,10 @@ function serializeLazyID(id: number): string {
1817
return '$L' + id.toString(16);
1818
}
1819
1820
+function serializeInfinitePromise(): string {
1821
+ return '$@';
1822
+}
1823
+
1824
function serializePromiseID(id: number): string {
1825
return '$@' + id.toString(16);
1826
}
@@ -3269,10 +3273,7 @@ function renderConsoleValue(
3273
}
3274
// If it hasn't already resolved (and been instrumented) we just encode an infinite
3275
// promise that will never resolve.
3272
- request.pendingChunks++;
3273
- const blockedId = request.nextChunkId++;
3274
- emitBlockedChunk(request, blockedId);
3275
- return serializePromiseID(blockedId);
3276
+ return serializeInfinitePromise();
3277
}
3278
3279
if (existingReference !== undefined) {