File tree Expand file tree Collapse file tree 1 file changed +18
-9
lines changed
src/browser/extension/inject Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -129,15 +129,24 @@ window.devToolsExtension.open = function(position) {
129129} ;
130130
131131// Catch non-reducer errors
132- function catchErrors ( e ) {
133- if ( window . devToolsOptions && ! window . devToolsOptions . notifyErrors ) return ;
134- window . postMessage ( {
135- source : 'redux-page' ,
136- type : 'ERROR' ,
137- message : e . message
138- } , '*' ) ;
139- }
140-
141132window . devToolsExtension . notifyErrors = function ( ) {
133+ let lastError = 0 ;
134+ function postError ( message ) {
135+ window . postMessage ( {
136+ source : 'redux-page' ,
137+ type : 'ERROR' ,
138+ message : message
139+ } , '*' ) ;
140+ }
141+ function catchErrors ( e ) {
142+ if ( window . devToolsOptions && ! window . devToolsOptions . notifyErrors ) return ;
143+ const timeout = ( window . devToolsOptions . timeout || 1 ) * 1000 ;
144+ if ( ! lastError ) {
145+ setTimeout ( ( ) => { postError ( e . message ) ; } , window . devToolsOptions . timeout ? timeout : 0 ) ;
146+ } else if ( lastError + timeout < e . timeStamp ) {
147+ postError ( e . message ) ;
148+ }
149+ lastError = e . timeStamp ;
150+ }
142151 window . addEventListener ( 'error' , catchErrors , false ) ;
143152} ;
You can’t perform that action at this time.
0 commit comments