File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -664,10 +664,16 @@ const createOverlay = (options) => {
664
664
if ( ! error && ! message ) {
665
665
return ;
666
666
}
667
+
667
668
// if error stack indicates a React error boundary caught the error, do not show overlay.
668
- if ( error . stack && error . stack . includes ( "invokeGuardedCallbackDev" ) ) {
669
+ if (
670
+ error &&
671
+ error . stack &&
672
+ error . stack . includes ( "invokeGuardedCallbackDev" )
673
+ ) {
669
674
return ;
670
675
}
676
+
671
677
handleError ( error , message ) ;
672
678
} ) ;
673
679
Original file line number Diff line number Diff line change 4
4
5
5
"use strict" ;
6
6
7
- const { createOverlay } = require ( "../../../ client-src/overlay" ) ;
7
+ const { createOverlay } = require ( "../../client-src/overlay" ) ;
8
8
9
9
describe ( "createOverlay" , ( ) => {
10
10
const originalDocument = global . document ;
@@ -108,6 +108,29 @@ describe("createOverlay", () => {
108
108
showOverlayMock . mockRestore ( ) ;
109
109
} ) ;
110
110
111
+ it ( "should show overlay for normal uncaught errors (when null is thrown)" , ( ) => {
112
+ const options = { trustedTypesPolicyName : null , catchRuntimeError : true } ;
113
+ const overlay = createOverlay ( options ) ;
114
+ const showOverlayMock = jest . spyOn ( overlay , "send" ) ;
115
+
116
+ const errorEvent = new ErrorEvent ( "error" , {
117
+ error : null ,
118
+ message : "error" ,
119
+ } ) ;
120
+ window . dispatchEvent ( errorEvent ) ;
121
+
122
+ expect ( showOverlayMock ) . toHaveBeenCalledWith ( {
123
+ type : "RUNTIME_ERROR" ,
124
+ messages : [
125
+ {
126
+ message : "error" ,
127
+ stack : expect . anything ( ) ,
128
+ } ,
129
+ ] ,
130
+ } ) ;
131
+ showOverlayMock . mockRestore ( ) ;
132
+ } ) ;
133
+
111
134
it ( "should show overlay for normal uncaught errors when catchRuntimeError is a function that return true" , ( ) => {
112
135
const options = {
113
136
trustedTypesPolicyName : null ,
You can’t perform that action at this time.
0 commit comments