File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3030 frameId,
3131 } , details ) ;
3232 try {
33- await browser . tabs . executeScript ( tabId , details ) ;
33+ for ( let attempts = 10 ; attempts -- > 0 ; ) {
34+ try {
35+ await browser . tabs . executeScript ( tabId , details ) ;
36+ } catch ( e ) {
37+ if ( ! / N o m a t c h i n g m e s s a g e h a n d l e r / . test ( e . message ) ) throw e ;
38+ debug ( "Couldn't inject script into %s: too early? Retrying up to %s times..." , url , attempts ) ;
39+ }
40+ }
3441 count ++ ;
3542 debug ( "Execute on start OK" , url , details ) ;
3643 } catch ( e ) {
Original file line number Diff line number Diff line change @@ -85,8 +85,13 @@ async function init() {
8585 debug ( "canScript:" , canScript ) ;
8686 } catch ( e ) {
8787 debug ( "Error querying canScript" , e ) ;
88- // background script not initialized yet?
89- setTimeout ( ( ) => init ( ) , 100 ) ;
88+ if ( document . readyState !== "complete" &&
89+ document . URL !== "about:blank" &&
90+ / R e c e i v i n g e n d d o e s n o t e x i s t / . test ( e . message ) ) {
91+ window . location . reload ( false ) ;
92+ } else {
93+ setTimeout ( ( ) => init ( ) , 100 ) ;
94+ }
9095 return ;
9196 } finally {
9297 queryingCanScript = false ;
You can’t perform that action at this time.
0 commit comments