Skip to content

Commit ab81262

Browse files
committed
Ignore errors with only node_module files
1 parent 4bae90d commit ab81262

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Diff for: packages/react-error-overlay/src/overlay.js

+4
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ function crash(error: Error, unhandledRejection = false) {
160160
}
161161
consumeError(error, unhandledRejection, CONTEXT_SIZE)
162162
.then(ref => {
163+
if (ref == null) {
164+
console.warn('react-error-overlay ignored:', error);
165+
return;
166+
}
163167
errorReferences.push(ref);
164168
if (iframeReference !== null && additionalReference !== null) {
165169
updateAdditional(

Diff for: packages/react-error-overlay/src/utils/errorRegister.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function consume(
1919
error: Error,
2020
unhandledRejection: boolean = false,
2121
contextSize: number = 3
22-
): Promise<ErrorRecordReference> {
22+
): Promise<ErrorRecordReference | null> {
2323
const parsedFrames = parse(error);
2424
let enhancedFramesPromise;
2525
if (error.__unmap_source) {
@@ -33,6 +33,13 @@ function consume(
3333
enhancedFramesPromise = map(parsedFrames, contextSize);
3434
}
3535
return enhancedFramesPromise.then(enhancedFrames => {
36+
if (
37+
enhancedFrames
38+
.map(f => f._originalFileName)
39+
.filter(f => f == null || f.indexOf('node_modules') === -1).length === 0
40+
) {
41+
return null;
42+
}
3643
enhancedFrames = enhancedFrames.filter(
3744
({ functionName }) =>
3845
functionName == null ||

0 commit comments

Comments
 (0)