GeezerVison is showing github.com — Update error message for suspending at sync priority (#23361) · react/react@3a60844
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMServerSuspense-test.internal.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -187,7 +187,7 @@ describe('ReactDOMServerSuspense', () => { | 187 | 187 | 1, | 188 | 188 | ); | 189 | 189 | }, | 190 | | - 'Add a <Suspense fallback=...> component higher in the tree', | | 190 | + 'A component suspended while responding to synchronous input.', | 191 | 191 | ); | 192 | 192 |
| 193 | 193 | itThrowsWhenRendering( | @@ -200,7 +200,7 @@ describe('ReactDOMServerSuspense', () => { | 200 | 200 | 1, | 201 | 201 | ); | 202 | 202 | }, | 203 | | - 'Add a <Suspense fallback=...> component higher in the tree', | | 203 | + 'A component suspended while responding to synchronous input.', | 204 | 204 | ); | 205 | 205 | } | 206 | 206 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/server/ReactDOMLegacyServerBrowser.js +6-4Lines changed: 6 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -78,11 +78,13 @@ function renderToStringImpl( | 78 | 78 | } | 79 | 79 |
| 80 | 80 | if (!readyToStream) { | | 81 | + // Note: This error message is the one we use on the client. It doesn't | | 82 | + // really make sense here. But this is the legacy server renderer, anyway. | | 83 | + // We're going to delete it soon. | 81 | 84 | throw new Error( | 82 | | - 'A React component suspended while rendering, but no fallback UI was specified.\n' + | 83 | | - '\n' + | 84 | | - 'Add a <Suspense fallback=...> component higher in the tree to ' + | 85 | | - 'provide a loading indicator or placeholder to display.', | | 85 | + 'A component suspended while responding to synchronous input. This ' + | | 86 | + 'will cause the UI to be replaced with a loading indicator. To fix, ' + | | 87 | + 'updates that suspend should be wrapped with startTransition.', | 86 | 88 | ); | 87 | 89 | } | 88 | 90 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberThrow.new.js +4-8Lines changed: 4 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -499,15 +499,11 @@ function throwException( | 499 | 499 | // This is a sync/discrete update. We treat this case like an error | 500 | 500 | // because discrete renders are expected to produce a complete tree | 501 | 501 | // synchronously to maintain consistency with external state. | 502 | | - | 503 | | - // TODO: We should never call getComponentNameFromFiber in production. | 504 | | - // Log a warning or something to prevent us from accidentally bundling it. | 505 | 502 | const uncaughtSuspenseError = new Error( | 506 | | - (getComponentNameFromFiber(sourceFiber) || 'A React component') + | 507 | | - ' suspended while rendering, but no fallback UI was specified.\n' + | 508 | | - '\n' + | 509 | | - 'Add a <Suspense fallback=...> component higher in the tree to ' + | 510 | | - 'provide a loading indicator or placeholder to display.', | | 503 | + 'A component suspended while responding to synchronous input. This ' + | | 504 | + 'will cause the UI to be replaced with a loading indicator. To ' + | | 505 | + 'fix, updates that suspend should be wrapped ' + | | 506 | + 'with startTransition.', | 511 | 507 | ); | 512 | 508 |
| 513 | 509 | // If we're outside a transition, fall through to the regular error path. | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberThrow.old.js +4-8Lines changed: 4 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -499,15 +499,11 @@ function throwException( | 499 | 499 | // This is a sync/discrete update. We treat this case like an error | 500 | 500 | // because discrete renders are expected to produce a complete tree | 501 | 501 | // synchronously to maintain consistency with external state. | 502 | | - | 503 | | - // TODO: We should never call getComponentNameFromFiber in production. | 504 | | - // Log a warning or something to prevent us from accidentally bundling it. | 505 | 502 | const uncaughtSuspenseError = new Error( | 506 | | - (getComponentNameFromFiber(sourceFiber) || 'A React component') + | 507 | | - ' suspended while rendering, but no fallback UI was specified.\n' + | 508 | | - '\n' + | 509 | | - 'Add a <Suspense fallback=...> component higher in the tree to ' + | 510 | | - 'provide a loading indicator or placeholder to display.', | | 503 | + 'A component suspended while responding to synchronous input. This ' + | | 504 | + 'will cause the UI to be replaced with a loading indicator. To ' + | | 505 | + 'fix, updates that suspend should be wrapped ' + | | 506 | + 'with startTransition.', | 511 | 507 | ); | 512 | 508 |
| 513 | 509 | // If we're outside a transition, fall through to the regular error path. | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js +1-3Lines changed: 1 addition & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1011,9 +1011,7 @@ describe('ReactSuspenseWithNoopRenderer', () => { | 1011 | 1011 | ReactNoop.flushSync(() => { | 1012 | 1012 | ReactNoop.render(<AsyncText text="Async" />); | 1013 | 1013 | }); | 1014 | | - }).toThrow( | 1015 | | - 'AsyncText suspended while rendering, but no fallback UI was specified.', | 1016 | | - ); | | 1014 | + }).toThrow('A component suspended while responding to synchronous input.'); | 1017 | 1015 | }); | 1018 | 1016 |
| 1019 | 1017 | // @gate enableCache | |
Collapse file Copy file name to clipboardExpand all lines: scripts/error-codes/codes.json +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 409 | 409 | "421": "There was an error while hydrating this Suspense boundary. Switched to client rendering.", | 410 | 410 | "422": "There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.", | 411 | 411 | "423": "This root received an early update, before anything was able hydrate. Switched the entire root to client rendering.", | 412 | | - "424": "Text content does not match server-rendered HTML." | | 412 | + "424": "Text content does not match server-rendered HTML.", | | 413 | + "425": "A component suspended while responding to synchronous input. This will cause the UI to be replaced with a loading indicator. To fix, updates that suspend should be wrapped with startTransition." | 413 | 414 | } |
|