Skip to content

Commit

Permalink
Make error overlay filename configurable (facebook#3028)
Browse files Browse the repository at this point in the history
* Make error overlay file configurable

* Add fallback filename
  • Loading branch information
jaredpalmer authored and thongdong7 committed Sep 24, 2017
1 parent 66b1a6f commit 8b911f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/react-dev-utils/webpackHotDevClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ErrorOverlay.startReportingRuntimeErrors({
module.hot.decline();
}
},
filename: 'static/js/bundle.js',
});

if (module.hot && typeof module.hot.dispose === 'function') {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-error-overlay/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type { ErrorRecord } from './listenToRuntimeErrors';
type RuntimeReportingOptions = {|
onError: () => void,
launchEditorEndpoint: string,
filename?: string,
|};

let iframe: null | HTMLIFrameElement = null;
Expand Down Expand Up @@ -55,7 +56,7 @@ export function startReportingRuntimeErrors(options: RuntimeReportingOptions) {
} finally {
handleRuntimeError(errorRecord);
}
});
}, options.filename);
}

function handleRuntimeError(errorRecord) {
Expand Down
7 changes: 5 additions & 2 deletions packages/react-error-overlay/src/listenToRuntimeErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export type ErrorRecord = {|
stackFrames: StackFrame[],
|};

export function listenToRuntimeErrors(crash: ErrorRecord => void) {
export function listenToRuntimeErrors(
crash: ErrorRecord => void,
filename: string = '/static/js/bundle.js'
) {
function crashWithFrames(error: Error, unhandledRejection = false) {
getStackFrames(error, unhandledRejection, CONTEXT_SIZE)
.then(stackFrames => {
Expand Down Expand Up @@ -68,7 +71,7 @@ export function listenToRuntimeErrors(crash: ErrorRecord => void) {
{
message: data.message,
stack: data.stack,
__unmap_source: '/static/js/bundle.js',
__unmap_source: filename,
},
false
);
Expand Down

0 comments on commit 8b911f3

Please sign in to comment.