Skip to content

Commit

Permalink
Log all errors to console.error by default (facebook#21130)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage authored and acdlite committed Apr 11, 2021
1 parent bbd849a commit c852abc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
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

0 comments on commit c852abc

Please sign in to comment.