Skip to content

Commit 9b4e024

Browse files
committed
Revert "[Fizz] Refactor Component Stack Nodes (facebook#30298)"
This reverts commit b73dcdc.
1 parent 163365a commit 9b4e024

File tree

9 files changed

+461
-346
lines changed

9 files changed

+461
-346
lines changed

packages/react-devtools-shared/src/backend/DevToolsFiberComponentStack.js

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export function describeFiber(
4747
case HostComponent:
4848
return describeBuiltInComponentFrame(workInProgress.type);
4949
case LazyComponent:
50-
// TODO: When we support Thenables as component types we should rename this.
5150
return describeBuiltInComponentFrame('Lazy');
5251
case SuspenseComponent:
5352
return describeBuiltInComponentFrame('Suspense');

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

+19-38
Original file line numberDiff line numberDiff line change
@@ -704,39 +704,17 @@ describe('ReactDOMFizzServer', () => {
704704

705705
it('should client render a boundary if a lazy component rejects', async () => {
706706
let rejectComponent;
707-
const promise = new Promise((resolve, reject) => {
708-
rejectComponent = reject;
709-
});
710707
const LazyComponent = React.lazy(() => {
711-
return promise;
712-
});
713-
714-
const LazyLazy = React.lazy(async () => {
715-
return {
716-
default: LazyComponent,
717-
};
718-
});
719-
720-
function Wrapper({children}) {
721-
return children;
722-
}
723-
const LazyWrapper = React.lazy(() => {
724-
return {
725-
then(callback) {
726-
callback({
727-
default: Wrapper,
728-
});
729-
},
730-
};
708+
return new Promise((resolve, reject) => {
709+
rejectComponent = reject;
710+
});
731711
});
732712

733713
function App({isClient}) {
734714
return (
735715
<div>
736716
<Suspense fallback={<Text text="Loading..." />}>
737-
<LazyWrapper>
738-
{isClient ? <Text text="Hello" /> : <LazyLazy text="Hello" />}
739-
</LazyWrapper>
717+
{isClient ? <Text text="Hello" /> : <LazyComponent text="Hello" />}
740718
</Suspense>
741719
</div>
742720
);
@@ -770,7 +748,6 @@ describe('ReactDOMFizzServer', () => {
770748
});
771749
pipe(writable);
772750
});
773-
774751
expect(loggedErrors).toEqual([]);
775752
expect(bootstrapped).toBe(true);
776753

@@ -799,7 +776,7 @@ describe('ReactDOMFizzServer', () => {
799776
'Switched to client rendering because the server rendering errored:\n\n' +
800777
theError.message,
801778
expectedDigest,
802-
componentStack(['Lazy', 'Wrapper', 'Suspense', 'div', 'App']),
779+
componentStack(['Lazy', 'Suspense', 'div', 'App']),
803780
],
804781
],
805782
[
@@ -879,9 +856,13 @@ describe('ReactDOMFizzServer', () => {
879856
}
880857

881858
await act(() => {
882-
const {pipe} = renderToPipeableStream(<App isClient={false} />, {
883-
onError,
884-
});
859+
const {pipe} = renderToPipeableStream(
860+
<App isClient={false} />,
861+
862+
{
863+
onError,
864+
},
865+
);
885866
pipe(writable);
886867
});
887868
expect(loggedErrors).toEqual([]);
@@ -919,7 +900,7 @@ describe('ReactDOMFizzServer', () => {
919900
'Switched to client rendering because the server rendering errored:\n\n' +
920901
theError.message,
921902
expectedDigest,
922-
componentStack(['Suspense', 'div', 'App']),
903+
componentStack(['Lazy', 'Suspense', 'div', 'App']),
923904
],
924905
],
925906
[
@@ -1418,13 +1399,13 @@ describe('ReactDOMFizzServer', () => {
14181399
'The render was aborted by the server without a reason.',
14191400
expectedDigest,
14201401
// We get the stack of the task when it was aborted which is why we see `h1`
1421-
componentStack(['AsyncText', 'h1', 'Suspense', 'div', 'App']),
1402+
componentStack(['h1', 'Suspense', 'div', 'App']),
14221403
],
14231404
[
14241405
'Switched to client rendering because the server rendering aborted due to:\n\n' +
14251406
'The render was aborted by the server without a reason.',
14261407
expectedDigest,
1427-
componentStack(['AsyncText', 'Suspense', 'main', 'div', 'App']),
1408+
componentStack(['Suspense', 'main', 'div', 'App']),
14281409
],
14291410
],
14301411
[
@@ -3526,13 +3507,13 @@ describe('ReactDOMFizzServer', () => {
35263507
'Switched to client rendering because the server rendering aborted due to:\n\n' +
35273508
'foobar',
35283509
'a digest',
3529-
componentStack(['AsyncText', 'Suspense', 'p', 'div', 'App']),
3510+
componentStack(['Suspense', 'p', 'div', 'App']),
35303511
],
35313512
[
35323513
'Switched to client rendering because the server rendering aborted due to:\n\n' +
35333514
'foobar',
35343515
'a digest',
3535-
componentStack(['AsyncText', 'Suspense', 'span', 'div', 'App']),
3516+
componentStack(['Suspense', 'span', 'div', 'App']),
35363517
],
35373518
],
35383519
[
@@ -3609,13 +3590,13 @@ describe('ReactDOMFizzServer', () => {
36093590
'Switched to client rendering because the server rendering aborted due to:\n\n' +
36103591
'uh oh',
36113592
'a digest',
3612-
componentStack(['AsyncText', 'Suspense', 'p', 'div', 'App']),
3593+
componentStack(['Suspense', 'p', 'div', 'App']),
36133594
],
36143595
[
36153596
'Switched to client rendering because the server rendering aborted due to:\n\n' +
36163597
'uh oh',
36173598
'a digest',
3618-
componentStack(['AsyncText', 'Suspense', 'span', 'div', 'App']),
3599+
componentStack(['Suspense', 'span', 'div', 'App']),
36193600
],
36203601
],
36213602
[

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ describe('ReactDOMFizzServerNode', () => {
585585
let isComplete = false;
586586
let rendered = false;
587587
const promise = new Promise(r => (resolve = r));
588-
function Wait({prop}) {
588+
function Wait() {
589589
if (!hasLoaded) {
590590
throw promise;
591591
}

packages/react-html/src/__tests__/ReactHTMLServer-test.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ if (!__EXPERIMENTAL__) {
250250
'\n in Bar (at **)' +
251251
'\n in Foo (at **)' +
252252
'\n in div (at **)'
253-
: '\n in div (at **)' + '\n in div (at **)',
253+
: '\n in Lazy (at **)' +
254+
'\n in div (at **)' +
255+
'\n in div (at **)',
254256
);
255257
expect(normalizeCodeLocInfo(caughtErrors[0].ownerStack)).toBe(
256258
__DEV__ && gate(flags => flags.enableOwnerStacks)

packages/react-reconciler/src/ReactFiberComponentStack.js

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ function describeFiber(fiber: Fiber): string {
3939
case HostComponent:
4040
return describeBuiltInComponentFrame(fiber.type);
4141
case LazyComponent:
42-
// TODO: When we support Thenables as component types we should rename this.
4342
return describeBuiltInComponentFrame('Lazy');
4443
case SuspenseComponent:
4544
return describeBuiltInComponentFrame('Suspense');

packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMEdge-test.js

-70
Original file line numberDiff line numberDiff line change
@@ -930,74 +930,4 @@ describe('ReactFlightDOMEdge', () => {
930930
'\n in Bar (at **)' + '\n in Foo (at **)',
931931
);
932932
});
933-
934-
it('supports server components in ssr component stacks', async () => {
935-
let reject;
936-
const promise = new Promise((_, r) => (reject = r));
937-
async function Erroring() {
938-
await promise;
939-
return 'should not render';
940-
}
941-
942-
const model = {
943-
root: ReactServer.createElement(Erroring),
944-
};
945-
946-
const stream = ReactServerDOMServer.renderToReadableStream(
947-
model,
948-
webpackMap,
949-
{
950-
onError() {},
951-
},
952-
);
953-
954-
const rootModel = await ReactServerDOMClient.createFromReadableStream(
955-
stream,
956-
{
957-
ssrManifest: {
958-
moduleMap: null,
959-
moduleLoading: null,
960-
},
961-
},
962-
);
963-
964-
const errors = [];
965-
const result = ReactDOMServer.renderToReadableStream(
966-
<div>{rootModel.root}</div>,
967-
{
968-
onError(error, {componentStack}) {
969-
errors.push({
970-
error,
971-
componentStack: normalizeCodeLocInfo(componentStack),
972-
});
973-
},
974-
},
975-
);
976-
977-
const theError = new Error('my error');
978-
reject(theError);
979-
980-
const expectedMessage = __DEV__
981-
? 'my error'
982-
: 'An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.';
983-
984-
try {
985-
await result;
986-
} catch (x) {
987-
expect(x).toEqual(
988-
expect.objectContaining({
989-
message: expectedMessage,
990-
}),
991-
);
992-
}
993-
994-
expect(errors).toEqual([
995-
{
996-
error: expect.objectContaining({
997-
message: expectedMessage,
998-
}),
999-
componentStack: (__DEV__ ? '\n in Erroring' : '') + '\n in div',
1000-
},
1001-
]);
1002-
});
1003933
});

0 commit comments

Comments
 (0)