Skip to content

Commit 8e1b6eb

Browse files
committed
[Flight] Revert Emit Infinite Promise as a Halted Row (facebook#30746)
This reverts commit 52c9c43.
1 parent 52c9c43 commit 8e1b6eb

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

packages/react-client/src/ReactFlightClient.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
enableRefAsProp,
4747
enableFlightReadableStream,
4848
enableOwnerStacks,
49+
enableHalt,
4950
} from 'shared/ReactFeatureFlags';
5051

5152
import {
@@ -1193,6 +1194,10 @@ function parseModelString(
11931194
}
11941195
case '@': {
11951196
// Promise
1197+
if (value.length === 2) {
1198+
// Infinite promise that never resolves.
1199+
return new Promise(() => {});
1200+
}
11961201
const id = parseInt(value.slice(2), 16);
11971202
const chunk = getChunk(response, id);
11981203
return chunk;
@@ -2633,8 +2638,10 @@ function processFullStringRow(
26332638
}
26342639
// Fallthrough
26352640
case 35 /* "#" */: {
2636-
resolveBlocked(response, id);
2637-
return;
2641+
if (enableHalt) {
2642+
resolveBlocked(response, id);
2643+
return;
2644+
}
26382645
}
26392646
// Fallthrough
26402647
default: /* """ "{" "[" "t" "f" "n" "0" - "9" */ {

packages/react-client/src/__tests__/ReactFlight-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3026,7 +3026,6 @@ describe('ReactFlight', () => {
30263026

30273027
const promise = mockConsoleLog.mock.calls[0][1].promise;
30283028
expect(promise).toBeInstanceOf(Promise);
3029-
expect(promise.status).toBe('blocked');
30303029

30313030
expect(ownerStacks).toEqual(['\n in App (at **)']);
30323031
});

packages/react-server/src/ReactFlightServer.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,10 @@ function serializeLazyID(id: number): string {
18171817
return '$L' + id.toString(16);
18181818
}
18191819

1820+
function serializeInfinitePromise(): string {
1821+
return '$@';
1822+
}
1823+
18201824
function serializePromiseID(id: number): string {
18211825
return '$@' + id.toString(16);
18221826
}
@@ -3269,10 +3273,7 @@ function renderConsoleValue(
32693273
}
32703274
// If it hasn't already resolved (and been instrumented) we just encode an infinite
32713275
// promise that will never resolve.
3272-
request.pendingChunks++;
3273-
const blockedId = request.nextChunkId++;
3274-
emitBlockedChunk(request, blockedId);
3275-
return serializePromiseID(blockedId);
3276+
return serializeInfinitePromise();
32763277
}
32773278

32783279
if (existingReference !== undefined) {

0 commit comments

Comments
 (0)