Skip to content

Commit

Permalink
Log all errors to console.error by default (#21130)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Mar 30, 2021
1 parent d1294c9 commit 0853aab
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
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
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
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 0853aab

Please sign in to comment.