Skip to content

Commit

Permalink
Same thing in Fizz
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Jun 11, 2024
1 parent 5712f0f commit a2b37b6
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/react-server/src/ReactFizzServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import {
resetResumableState,
completeResumableState,
emitEarlyPreloads,
printToConsole,
} from './ReactFizzConfig';
import {
constructClassInstance,
Expand Down Expand Up @@ -359,7 +360,21 @@ export opaque type Request = {
const DEFAULT_PROGRESSIVE_CHUNK_SIZE = 12800;

function defaultErrorHandler(error: mixed) {
console['error'](error); // Don't transform to our wrapper
if (
typeof error === 'object' &&
error !== null &&
typeof error.environmentName === 'string'
) {
// This was a Server error. We print the environment name in a badge just like we do with
// replays of console logs to indicate that the source of this throw as actually the Server.
printToConsole(
'error',
[error],
error.environmentName,
);
} else {
console['error'](error); // Don't transform to our wrapper
}
return null;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/react-server/src/forks/ReactFizzConfig.custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export const isPrimaryRenderer = false;
export const supportsRequestStorage = false;
export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);

export const printToConsole = $$$config.printToConsole;

export const resetResumableState = $$$config.resetResumableState;
export const completeResumableState = $$$config.completeResumableState;
export const getChildFormatContext = $$$config.getChildFormatContext;
Expand Down
2 changes: 2 additions & 0 deletions packages/react-server/src/forks/ReactFizzConfig.dom-edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import type {Request} from 'react-server/src/ReactFizzServer';

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

export * from 'react-client/src/ReactClientConsoleConfigServer';

// For now, we get this from the global scope, but this will likely move to a module.
export const supportsRequestStorage = typeof AsyncLocalStorage === 'function';
export const requestStorage: AsyncLocalStorage<Request | void> =
Expand Down
2 changes: 2 additions & 0 deletions packages/react-server/src/forks/ReactFizzConfig.dom-legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ import type {Request} from 'react-server/src/ReactFizzServer';

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

export * from 'react-client/src/ReactClientConsoleConfigPlain';

export const supportsRequestStorage = false;
export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
2 changes: 2 additions & 0 deletions packages/react-server/src/forks/ReactFizzConfig.dom-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import type {Request} from 'react-server/src/ReactFizzServer';

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

export * from 'react-client/src/ReactClientConsoleConfigServer';

export const supportsRequestStorage = true;
export const requestStorage: AsyncLocalStorage<Request | void> =
new AsyncLocalStorage();
2 changes: 2 additions & 0 deletions packages/react-server/src/forks/ReactFizzConfig.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ import type {Request} from 'react-server/src/ReactFizzServer';

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

export * from 'react-client/src/ReactClientConsoleConfigBrowser';

export const supportsRequestStorage = false;
export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);

0 comments on commit a2b37b6

Please sign in to comment.