@@ -84,8 +84,15 @@ const decodeOverlayOptions = (overlayOptions) => {
8484const status = {
8585 isUnloading : false ,
8686 currentHash : __webpack_hash__ ,
87+ hasRuntimeError : false ,
8788} ;
89+ window . addEventListener ( "error" , ( ) => {
90+ status . hasRuntimeError = true ;
91+ } ) ;
8892
93+ window . addEventListener ( "unhandledrejection" , ( ) => {
94+ status . hasRuntimeError = true ;
95+ } ) ;
8996/**
9097 * @returns {string } current script source
9198 */
@@ -403,8 +410,7 @@ const onSocketMessage = {
403410 invalid ( ) {
404411 log . info ( "App updated. Recompiling..." ) ;
405412
406- // Fixes #1042. overlay doesn't clear if errors are fixed but warnings remain.
407- if ( options . overlay ) {
413+ if ( options . overlay && ! status . hasRuntimeError ) {
408414 overlay . send ( { type : "DISMISS" } ) ;
409415 }
410416
@@ -473,7 +479,7 @@ const onSocketMessage = {
473479 "still-ok" : function stillOk ( ) {
474480 log . info ( "Nothing changed." ) ;
475481
476- if ( options . overlay ) {
482+ if ( options . overlay && ! status . hasRuntimeError ) {
477483 overlay . send ( { type : "DISMISS" } ) ;
478484 }
479485
@@ -482,6 +488,8 @@ const onSocketMessage = {
482488 ok ( ) {
483489 sendMessage ( "Ok" ) ;
484490
491+ status . hasRuntimeError = false ;
492+
485493 if ( options . overlay ) {
486494 overlay . send ( { type : "DISMISS" } ) ;
487495 }
0 commit comments