Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fizz/Flight] Log all errors to console.error by default on the server #21130

Merged
merged 1 commit into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions packages/react-client/src/__tests__/ReactFlight-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,15 @@ describe('ReactFlight', () => {
return <div ref={ref} />;
}

const event = ReactNoopFlightServer.render(<EventHandlerProp />);
const fn = ReactNoopFlightServer.render(<FunctionProp />);
const symbol = ReactNoopFlightServer.render(<SymbolProp />);
const refs = ReactNoopFlightServer.render(<RefProp />);
const options = {
onError() {
// ignore
},
};
const event = ReactNoopFlightServer.render(<EventHandlerProp />, options);
const fn = ReactNoopFlightServer.render(<FunctionProp />, options);
const symbol = ReactNoopFlightServer.render(<SymbolProp />, options);
const refs = ReactNoopFlightServer.render(<RefProp />, options);

function Client({transport}) {
return ReactNoopFlightClient.read(transport);
Expand Down Expand Up @@ -213,7 +218,11 @@ describe('ReactFlight', () => {
);
}

const data = ReactNoopFlightServer.render(<Server />);
const data = ReactNoopFlightServer.render(<Server />, {
onError(x) {
// ignore
},
});

function Client({transport}) {
return ReactNoopFlightClient.read(transport);
Expand Down
6 changes: 5 additions & 1 deletion packages/react-server/src/ReactFizzServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,17 @@ type Request = {
// 500 * 1024 / 8 * .8 * 0.5 / 2
const DEFAULT_PROGRESSIVE_CHUNK_SIZE = 12800;

function defaultErrorHandler(error: mixed) {
console['error'](error); // Don't transform to our wrapper
}

export function createRequest(
children: ReactNodeList,
destination: Destination,
responseState: ResponseState,
rootContext: FormatContext,
progressiveChunkSize: number = DEFAULT_PROGRESSIVE_CHUNK_SIZE,
onError: (error: mixed) => void = noop,
onError: (error: mixed) => void = defaultErrorHandler,
onCompleteAll: () => void = noop,
onReadyToStream: () => void = noop,
): Request {
Expand Down
4 changes: 3 additions & 1 deletion packages/react-server/src/ReactFlightServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ export type Request = {

const ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;

function defaultErrorHandler() {}
function defaultErrorHandler(error: mixed) {
console['error'](error); // Don't transform to our wrapper
}

export function createRequest(
model: ReactModel,
Expand Down