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) => {
664664 if ( ! error && ! message ) {
665665 return ;
666666 }
667+
667668 // 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+ ) {
669674 return ;
670675 }
676+
671677 handleError ( error , message ) ;
672678 } ) ;
673679
Original file line number Diff line number Diff line change 44
55"use strict" ;
66
7- const { createOverlay } = require ( "../../../ client-src/overlay" ) ;
7+ const { createOverlay } = require ( "../../client-src/overlay" ) ;
88
99describe ( "createOverlay" , ( ) => {
1010 const originalDocument = global . document ;
@@ -108,6 +108,29 @@ describe("createOverlay", () => {
108108 showOverlayMock . mockRestore ( ) ;
109109 } ) ;
110110
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+
111134 it ( "should show overlay for normal uncaught errors when catchRuntimeError is a function that return true" , ( ) => {
112135 const options = {
113136 trustedTypesPolicyName : null ,
You can’t perform that action at this time.
0 commit comments