GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Emit Infinite Promise as a Halted Row · react/react@c7ab906

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • react-client/src
      • ReactFlightClient.js
      • __tests__
        • ReactFlight-test.js
    • react-server/src
      • ReactFlightServer.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/react-client/src/ReactFlightClient.js‎

Copy file name to clipboardExpand all lines: packages/react-client/src/ReactFlightClient.js
+2-9Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import {
4545
enableRefAsProp,
4646
enableFlightReadableStream,
4747
enableOwnerStacks,
48-
enableHalt,
4948
} from 'shared/ReactFeatureFlags';
5049

5150
import {
@@ -1193,10 +1192,6 @@ function parseModelString(
11931192
}
11941193
case '@': {
11951194
// Promise
1196-
if (value.length === 2) {
1197-
// Infinite promise that never resolves.
1198-
return new Promise(() => {});
1199-
}
12001195
const id = parseInt(value.slice(2), 16);
12011196
const chunk = getChunk(response, id);
12021197
return chunk;
@@ -2634,10 +2629,8 @@ function processFullStringRow(
26342629
}
26352630
// Fallthrough
26362631
case 35 /* "#" */: {
2637-
if (enableHalt) {
2638-
resolveBlocked(response, id);
2639-
return;
2640-
}
2632+
resolveBlocked(response, id);
2633+
return;
26412634
}
26422635
// Fallthrough
26432636
default: /* """ "{" "[" "t" "f" "n" "0" - "9" */ {
Collapse file

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

Copy file name to clipboardExpand all lines: packages/react-client/src/__tests__/ReactFlight-test.js
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2952,8 +2952,14 @@ describe('ReactFlight', () => {
29522952
function foo() {
29532953
return 'hello';
29542954
}
2955+
29552956
function ServerComponent() {
2956-
console.log('hi', {prop: 123, fn: foo, map: new Map([['foo', foo]])});
2957+
console.log('hi', {
2958+
prop: 123,
2959+
fn: foo,
2960+
map: new Map([['foo', foo]]),
2961+
promise: new Promise(() => {}),
2962+
});
29572963
throw new Error('err');
29582964
}
29592965

@@ -3018,6 +3024,10 @@ describe('ReactFlight', () => {
30183024
expect(loggedFn2).not.toBe(foo);
30193025
expect(loggedFn2.toString()).toBe(foo.toString());
30203026

3027+
const promise = mockConsoleLog.mock.calls[0][1].promise;
3028+
expect(promise).toBeInstanceOf(Promise);
3029+
expect(promise.status).toBe('blocked');
3030+
30213031
expect(ownerStacks).toEqual(['\n in App (at **)']);
30223032
});
30233033

Collapse file

‎packages/react-server/src/ReactFlightServer.js‎

Copy file name to clipboardExpand all lines: packages/react-server/src/ReactFlightServer.js
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,10 +1815,6 @@ function serializeLazyID(id: number): string {
18151815
return '$L' + id.toString(16);
18161816
}
18171817

1818-
function serializeInfinitePromise(): string {
1819-
return '$@';
1820-
}
1821-
18221818
function serializePromiseID(id: number): string {
18231819
return '$@' + id.toString(16);
18241820
}
@@ -3241,7 +3237,10 @@ function renderConsoleValue(
32413237
}
32423238
// If it hasn't already resolved (and been instrumented) we just encode an infinite
32433239
// promise that will never resolve.
3244-
return serializeInfinitePromise();
3240+
request.pendingChunks++;
3241+
const blockedId = request.nextChunkId++;
3242+
emitBlockedChunk(request, blockedId);
3243+
return serializePromiseID(blockedId);
32453244
}
32463245

32473246
if (existingReference !== undefined) {
@@ -3502,7 +3501,7 @@ function emitConsoleChunk(
35023501
value,
35033502
);
35043503
} catch (x) {
3505-
return 'unknown value';
3504+
return 'unknown value' + x.message;
35063505
}
35073506
}
35083507

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.