Log all errors to console.error by default (#21130)

This commit is contained in:
Sebastian Markbåge 2021-03-29 22:39:55 -04:00 committed by GitHub
parent d1294c9d40
commit 0853aab74d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 7 deletions

View File

@ -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);
@ -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);

View File

@ -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 {

View File

@ -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,