Skip to content

Commit eb9f4a5

Browse files
committed
Update (base update)
[ghstack-poisoned]
2 parents c23e432 + e6783e7 commit eb9f4a5

File tree

6 files changed

+113
-31
lines changed

6 files changed

+113
-31
lines changed

.github/workflows/runtime_build.yml

+18-14
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,30 @@ on:
77
paths-ignore:
88
- 'compiler/**'
99

10+
env:
11+
WORKER_COUNT: 20
12+
1013
jobs:
1114
define_build_params:
1215
name: Build build params
1316
runs-on: ubuntu-latest
1417
outputs:
15-
bundle_type: ${{ steps.define_bundle_types.outputs.result }}
18+
worker_id: ${{ steps.define_worker_id.outputs.result }}
1619
release_channel: ${{ steps.define_release_channels.outputs.result }}
1720
steps:
1821
- uses: actions/checkout@v4
1922
- uses: actions/github-script@v7
20-
id: define_bundle_types
23+
id: define_worker_id
2124
with:
2225
script: |
23-
const {bundleTypes} = require('./scripts/rollup/bundles');
24-
return Object.values(bundleTypes);
26+
function range(from, to) {
27+
const arr = [];
28+
for (let n = from; n < to; n++) {
29+
arr.push(n);
30+
}
31+
return arr;
32+
}
33+
return range(0, process.env.WORKER_COUNT);
2534
- uses: actions/github-script@v7
2635
id: define_release_channels
2736
with:
@@ -34,7 +43,7 @@ jobs:
3443
needs: define_build_params
3544
strategy:
3645
matrix:
37-
bundle_type: ${{ fromJSON(needs.define_build_params.outputs.bundle_type) }}
46+
worker_id: ${{ fromJSON(needs.define_build_params.outputs.worker_id) }}
3847
release_channel: ${{ fromJSON(needs.define_build_params.outputs.release_channel) }}
3948
steps:
4049
- uses: actions/checkout@v4
@@ -50,7 +59,7 @@ jobs:
5059
path: "**/node_modules"
5160
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
5261
- run: yarn install --frozen-lockfile
53-
- run: yarn build --b=${{ matrix.bundle_type }} --r=${{ matrix.release_channel }} --ci=github
62+
- run: yarn build --index=${{ matrix.worker_id }} --total=${{ env.WORKER_COUNT }} --r=${{ matrix.release_channel }} --ci=github
5463
env:
5564
CI: github
5665
RELEASE_CHANNEL: ${{ matrix.release_channel }}
@@ -59,18 +68,13 @@ jobs:
5968
- name: Archive build
6069
uses: actions/upload-artifact@v4
6170
with:
62-
name: ${{ matrix.bundle_type }}_${{ matrix.release_channel }}
71+
name: build_${{ matrix.worker_id }}_${{ matrix.release_channel }}
6372
path: |
6473
build
6574
6675
lint_build:
6776
name: yarn lint-build
68-
needs: [define_build_params, build]
69-
strategy:
70-
matrix:
71-
bundle_type: ${{ fromJSON(needs.define_build_params.outputs.bundle_type) }}
72-
release_channel: ${{ fromJSON(needs.define_build_params.outputs.release_channel) }}
73-
continue-on-error: true
77+
needs: build
7478
runs-on: ubuntu-latest
7579
steps:
7680
- uses: actions/checkout@v4
@@ -89,8 +93,8 @@ jobs:
8993
- name: Restore archived build
9094
uses: actions/download-artifact@v4
9195
with:
92-
name: ${{ matrix.bundle_type }}_${{ matrix.release_channel }}
9396
path: build
97+
merge-multiple: true
9498
- name: Display structure of build
9599
run: ls -R build
96100
- run: yarn lint-build

fixtures/flight/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@
7070
"predev": "cp -r ../../build/oss-experimental/* ./node_modules/",
7171
"prebuild": "cp -r ../../build/oss-experimental/* ./node_modules/",
7272
"dev": "concurrently \"npm run dev:region\" \"npm run dev:global\"",
73-
"dev:global": "NODE_ENV=development BUILD_PATH=dist node --experimental-loader ./loader/global.js server/global",
74-
"dev:region": "NODE_ENV=development BUILD_PATH=dist nodemon --watch src --watch dist -- --enable-source-maps --experimental-loader ./loader/region.js --conditions=react-server server/region",
73+
"dev:global": "NODE_ENV=development BUILD_PATH=dist node --experimental-loader ./loader/global.js --inspect=127.0.0.1:9230 server/global",
74+
"dev:region": "NODE_ENV=development BUILD_PATH=dist nodemon --watch src --watch dist -- --enable-source-maps --experimental-loader ./loader/region.js --conditions=react-server --inspect=127.0.0.1:9229 server/region",
7575
"start": "node scripts/build.js && concurrently \"npm run start:region\" \"npm run start:global\"",
7676
"start:global": "NODE_ENV=production node --experimental-loader ./loader/global.js server/global",
7777
"start:region": "NODE_ENV=production node --experimental-loader ./loader/region.js --conditions=react-server server/region",

packages/react-server/src/ReactFizzServer.js

+39
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ import {
150150
disableDefaultPropsExceptForClasses,
151151
enableAsyncIterableChildren,
152152
disableStringRefs,
153+
enableOwnerStacks,
153154
} from 'shared/ReactFeatureFlags';
154155

155156
import assign from 'shared/assign';
@@ -2372,6 +2373,27 @@ function renderNodeDestructive(
23722373
key == null ? (childIndex === -1 ? 0 : childIndex) : key;
23732374
const keyPath = [task.keyPath, name, keyOrIndex];
23742375
if (task.replay !== null) {
2376+
if (__DEV__ && enableOwnerStacks) {
2377+
const debugTask: null | ConsoleTask = element._debugTask;
2378+
if (debugTask) {
2379+
debugTask.run(
2380+
replayElement.bind(
2381+
null,
2382+
request,
2383+
task,
2384+
keyPath,
2385+
name,
2386+
keyOrIndex,
2387+
childIndex,
2388+
type,
2389+
props,
2390+
ref,
2391+
task.replay,
2392+
),
2393+
);
2394+
return;
2395+
}
2396+
}
23752397
replayElement(
23762398
request,
23772399
task,
@@ -2388,6 +2410,23 @@ function renderNodeDestructive(
23882410
// prelude and skip it during the replay.
23892411
} else {
23902412
// We're doing a plain render.
2413+
if (__DEV__ && enableOwnerStacks) {
2414+
const debugTask: null | ConsoleTask = element._debugTask;
2415+
if (debugTask) {
2416+
debugTask.run(
2417+
renderElement.bind(
2418+
null,
2419+
request,
2420+
task,
2421+
keyPath,
2422+
type,
2423+
props,
2424+
ref,
2425+
),
2426+
);
2427+
return;
2428+
}
2429+
}
23912430
renderElement(request, task, keyPath, type, props, ref);
23922431
}
23932432
return;

packages/react-server/src/ReactFlightServer.js

+39-3
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ function getStack(error: Error): string {
168168

169169
function initCallComponentFrame(): string {
170170
// Extract the stack frame of the callComponentInDEV function.
171-
const error = callComponentInDEV(Error, 'react-stack-top-frame', {});
171+
const error = callComponentInDEV(Error, 'react-stack-top-frame', {}, null);
172172
const stack = getStack(error);
173173
const startIdx = stack.startsWith('Error: react-stack-top-frame\n') ? 29 : 0;
174174
const endIdx = stack.indexOf('\n', startIdx);
@@ -991,20 +991,36 @@ function callComponentInDEV<Props, R>(
991991
Component: (p: Props, arg: void) => R,
992992
props: Props,
993993
componentDebugInfo: ReactComponentInfo,
994+
debugTask: null | ConsoleTask,
994995
): R {
995996
// The secondArg is always undefined in Server Components since refs error early.
996997
const secondArg = undefined;
997998
setCurrentOwner(componentDebugInfo);
998999
try {
9991000
if (supportsComponentStorage) {
10001001
// Run the component in an Async Context that tracks the current owner.
1002+
if (enableOwnerStacks && debugTask) {
1003+
return debugTask.run(
1004+
// $FlowFixMe[method-unbinding]
1005+
componentStorage.run.bind(
1006+
componentStorage,
1007+
componentDebugInfo,
1008+
Component,
1009+
props,
1010+
secondArg,
1011+
),
1012+
);
1013+
}
10011014
return componentStorage.run(
10021015
componentDebugInfo,
10031016
Component,
10041017
props,
10051018
secondArg,
10061019
);
10071020
} else {
1021+
if (enableOwnerStacks && debugTask) {
1022+
return debugTask.run(Component.bind(null, props, secondArg));
1023+
}
10081024
return Component(props, secondArg);
10091025
}
10101026
} finally {
@@ -1028,6 +1044,7 @@ function renderFunctionComponent<Props>(
10281044
props: Props,
10291045
owner: null | ReactComponentInfo, // DEV-only
10301046
stack: null | string, // DEV-only
1047+
debugTask: null | ConsoleTask, // DEV-only
10311048
validated: number, // DEV-only
10321049
): ReactJSONValue {
10331050
// Reset the task's thenable state before continuing, so that if a later
@@ -1075,11 +1092,22 @@ function renderFunctionComponent<Props>(
10751092
task.environmentName = componentEnv;
10761093

10771094
if (enableOwnerStacks) {
1078-
warnForMissingKey(request, key, validated, componentDebugInfo);
1095+
warnForMissingKey(
1096+
request,
1097+
key,
1098+
validated,
1099+
componentDebugInfo,
1100+
debugTask,
1101+
);
10791102
}
10801103
}
10811104
prepareToUseHooksForComponent(prevThenableState, componentDebugInfo);
1082-
result = callComponentInDEV(Component, props, componentDebugInfo);
1105+
result = callComponentInDEV(
1106+
Component,
1107+
props,
1108+
componentDebugInfo,
1109+
debugTask,
1110+
);
10831111
} else {
10841112
prepareToUseHooksForComponent(prevThenableState, null);
10851113
// The secondArg is always undefined in Server Components since refs error early.
@@ -1235,6 +1263,7 @@ function warnForMissingKey(
12351263
key: null | string,
12361264
validated: number,
12371265
componentDebugInfo: ReactComponentInfo,
1266+
debugTask: null | ConsoleTask,
12381267
): void {
12391268
if (__DEV__) {
12401269
if (validated !== 2) {
@@ -1267,6 +1296,7 @@ function warnForMissingKey(
12671296
},
12681297
null,
12691298
componentDebugInfo,
1299+
debugTask,
12701300
);
12711301
}
12721302
}
@@ -1482,6 +1512,7 @@ function renderElement(
14821512
props: any,
14831513
owner: null | ReactComponentInfo, // DEV only
14841514
stack: null | string, // DEV only
1515+
debugTask: null | ConsoleTask, // DEV only
14851516
validated: number, // DEV only
14861517
): ReactJSONValue {
14871518
if (ref !== null && ref !== undefined) {
@@ -1514,6 +1545,7 @@ function renderElement(
15141545
props,
15151546
owner,
15161547
stack,
1548+
debugTask,
15171549
validated,
15181550
);
15191551
} else if (type === REACT_FRAGMENT_TYPE && key === null) {
@@ -1562,6 +1594,7 @@ function renderElement(
15621594
props,
15631595
owner,
15641596
stack,
1597+
debugTask,
15651598
validated,
15661599
);
15671600
}
@@ -1574,6 +1607,7 @@ function renderElement(
15741607
props,
15751608
owner,
15761609
stack,
1610+
debugTask,
15771611
validated,
15781612
);
15791613
}
@@ -1587,6 +1621,7 @@ function renderElement(
15871621
props,
15881622
owner,
15891623
stack,
1624+
debugTask,
15901625
validated,
15911626
);
15921627
}
@@ -2190,6 +2225,7 @@ function renderModelDestructive(
21902225
? element._debugStack
21912226
: filterDebugStack(element._debugStack)
21922227
: null,
2228+
__DEV__ && enableOwnerStacks ? element._debugTask : null,
21932229
__DEV__ && enableOwnerStacks ? element._store.validated : 0,
21942230
);
21952231
if (

scripts/rollup/build-all-release-channels.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const {
1616
rcNumber,
1717
} = require('../../ReactVersions');
1818
const yargs = require('yargs');
19-
const Bundles = require('./bundles');
2019
const {buildEverything} = require('./build-ghaction');
2120

2221
// Runs the build script for both stable and experimental release channels,
@@ -65,12 +64,17 @@ const argv = yargs.wrap(yargs.terminalWidth()).options({
6564
default: 'experimental',
6665
choices: ['experimental', 'stable'],
6766
},
68-
bundleType: {
69-
alias: 'b',
70-
describe: 'Build the given bundle type.',
67+
index: {
68+
alias: 'i',
69+
describe: 'Worker id.',
7170
requiresArg: true,
72-
type: 'string',
73-
choices: Object.values(Bundles.bundleTypes),
71+
type: 'number',
72+
},
73+
total: {
74+
alias: 't',
75+
describe: 'Total number of workers.',
76+
requiresArg: true,
77+
type: 'number',
7478
},
7579
ci: {
7680
describe: 'Run tests in CI',
@@ -82,7 +86,7 @@ const argv = yargs.wrap(yargs.terminalWidth()).options({
8286

8387
async function main() {
8488
if (argv.ci === 'github') {
85-
await buildEverything(argv.bundleType);
89+
await buildEverything(argv.index, argv.total);
8690
switch (argv.releaseChannel) {
8791
case 'stable': {
8892
processStable('./build');

scripts/rollup/build-ghaction.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ function handleRollupError(error) {
803803
}
804804
}
805805

806-
async function buildEverything(bundleTypeToBuild) {
806+
async function buildEverything(index, total) {
807807
if (!argv['unsafe-partial']) {
808808
await asyncRimRaf('build');
809809
}
@@ -840,10 +840,9 @@ async function buildEverything(bundleTypeToBuild) {
840840
return !shouldSkipBundle(bundle, bundleType);
841841
});
842842

843-
// TODO: cleanup the rest of this function
844-
bundles = bundles.filter(
845-
([, bundleType]) => bundleType === bundleTypeToBuild
846-
);
843+
const nodeTotal = parseInt(total, 10);
844+
const nodeIndex = parseInt(index, 10);
845+
bundles = bundles.filter((_, i) => i % nodeTotal === nodeIndex);
847846

848847
await Promise.all(
849848
bundles.map(([bundle, bundleType]) => createBundle(bundle, bundleType))

0 commit comments

Comments
 (0)