@@ -47,7 +47,8 @@ const serial = {
4747 self . connectionType = 'serial' ;
4848
4949 chrome . serial . connect ( path , options , function ( connectionInfo ) {
50- if ( connectionInfo && ! self . openCanceled && ! checkChromeRuntimeError ( ) ) {
50+ self . failed = checkChromeRuntimeError ( ) ;
51+ if ( connectionInfo && ! self . openCanceled && ! self . failed ) {
5152 self . connected = true ;
5253 self . connectionId = connectionInfo . connectionId ;
5354 self . bitrate = connectionInfo . bitrate ;
@@ -65,6 +66,7 @@ const serial = {
6566 if ( ! self . failed ++ ) {
6667 chrome . serial . setPaused ( self . connectionId , false , function ( ) {
6768 self . getInfo ( function ( getInfo ) {
69+ checkChromeRuntimeError ( ) ;
6870 if ( getInfo ) {
6971 if ( ! getInfo . paused ) {
7072 console . log ( `${ self . connectionType } : connection recovered from last onReceiveError` ) ;
@@ -74,8 +76,6 @@ const serial = {
7476 gui_log ( i18n . getMessage ( 'serialUnrecoverable' ) ) ;
7577 self . errorHandler ( getInfo . error , 'receive' ) ;
7678 }
77- } else {
78- checkChromeRuntimeError ( ) ;
7979 }
8080 } ) ;
8181 } ) ;
@@ -87,13 +87,14 @@ const serial = {
8787 self . error = info . error ;
8888 setTimeout ( function ( ) {
8989 chrome . serial . setPaused ( info . connectionId , false , function ( ) {
90- self . getInfo ( function ( _info ) {
91- if ( _info ) {
92- if ( _info . paused ) {
90+ checkChromeRuntimeError ( ) ;
91+ self . getInfo ( function ( getInfo ) {
92+ if ( getInfo ) {
93+ if ( getInfo . paused ) {
9394 // assume unrecoverable, disconnect
9495 console . log ( `${ self . connectionType } : connection did not recover from ${ self . error } condition, disconnecting` ) ;
9596 gui_log ( i18n . getMessage ( 'serialUnrecoverable' ) ) ;
96- self . errorHandler ( _info . error , 'receive' ) ;
97+ self . errorHandler ( getInfo . error , 'receive' ) ;
9798 }
9899 else {
99100 console . log ( `${ self . connectionType } : connection recovered from ${ self . error } condition` ) ;
0 commit comments