Skip to content

Commit a2b37b6

Browse files
committed
Same thing in Fizz
1 parent 5712f0f commit a2b37b6

File tree

6 files changed

+26
-1
lines changed

6 files changed

+26
-1
lines changed

packages/react-server/src/ReactFizzServer.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import {
7878
resetResumableState,
7979
completeResumableState,
8080
emitEarlyPreloads,
81+
printToConsole,
8182
} from './ReactFizzConfig';
8283
import {
8384
constructClassInstance,
@@ -359,7 +360,21 @@ export opaque type Request = {
359360
const DEFAULT_PROGRESSIVE_CHUNK_SIZE = 12800;
360361

361362
function defaultErrorHandler(error: mixed) {
362-
console['error'](error); // Don't transform to our wrapper
363+
if (
364+
typeof error === 'object' &&
365+
error !== null &&
366+
typeof error.environmentName === 'string'
367+
) {
368+
// This was a Server error. We print the environment name in a badge just like we do with
369+
// replays of console logs to indicate that the source of this throw as actually the Server.
370+
printToConsole(
371+
'error',
372+
[error],
373+
error.environmentName,
374+
);
375+
} else {
376+
console['error'](error); // Don't transform to our wrapper
377+
}
363378
return null;
364379
}
365380

packages/react-server/src/forks/ReactFizzConfig.custom.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export const isPrimaryRenderer = false;
4040
export const supportsRequestStorage = false;
4141
export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
4242

43+
export const printToConsole = $$$config.printToConsole;
44+
4345
export const resetResumableState = $$$config.resetResumableState;
4446
export const completeResumableState = $$$config.completeResumableState;
4547
export const getChildFormatContext = $$$config.getChildFormatContext;

packages/react-server/src/forks/ReactFizzConfig.dom-edge.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import type {Request} from 'react-server/src/ReactFizzServer';
1010

1111
export * from 'react-dom-bindings/src/server/ReactFizzConfigDOM';
1212

13+
export * from 'react-client/src/ReactClientConsoleConfigServer';
14+
1315
// For now, we get this from the global scope, but this will likely move to a module.
1416
export const supportsRequestStorage = typeof AsyncLocalStorage === 'function';
1517
export const requestStorage: AsyncLocalStorage<Request | void> =

packages/react-server/src/forks/ReactFizzConfig.dom-legacy.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ import type {Request} from 'react-server/src/ReactFizzServer';
1010

1111
export * from 'react-dom-bindings/src/server/ReactFizzConfigDOMLegacy';
1212

13+
export * from 'react-client/src/ReactClientConsoleConfigPlain';
14+
1315
export const supportsRequestStorage = false;
1416
export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);

packages/react-server/src/forks/ReactFizzConfig.dom-node.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import type {Request} from 'react-server/src/ReactFizzServer';
1313

1414
export * from 'react-dom-bindings/src/server/ReactFizzConfigDOM';
1515

16+
export * from 'react-client/src/ReactClientConsoleConfigServer';
17+
1618
export const supportsRequestStorage = true;
1719
export const requestStorage: AsyncLocalStorage<Request | void> =
1820
new AsyncLocalStorage();

packages/react-server/src/forks/ReactFizzConfig.dom.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ import type {Request} from 'react-server/src/ReactFizzServer';
1010

1111
export * from 'react-dom-bindings/src/server/ReactFizzConfigDOM';
1212

13+
export * from 'react-client/src/ReactClientConsoleConfigBrowser';
14+
1315
export const supportsRequestStorage = false;
1416
export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);

0 commit comments

Comments
 (0)