File tree Expand file tree Collapse file tree 3 files changed +29
-8
lines changed
arduino-ide-extension/src Expand file tree Collapse file tree 3 files changed +29
-8
lines changed Original file line number Diff line number Diff line change @@ -131,14 +131,22 @@ export class VerifySketch extends CoreServiceContribution {
131131 'arduino/sketch/compile' ,
132132 'Compiling sketch...'
133133 ) ,
134- task : ( progressId , coreService , token ) =>
135- coreService . compile (
136- {
137- ...options ,
138- progressId,
139- } ,
140- token
141- ) ,
134+ task : async ( progressId , coreService , token ) => {
135+ const compile = ( ) =>
136+ coreService . compile ( { ...options , progressId } , token ) ;
137+
138+ try {
139+ await compile ( ) ;
140+ } catch ( e ) {
141+ if ( e . code === 4006 ) {
142+ // If client instance is expired, silently refresh and retry
143+ await coreService . refresh ( ) ;
144+ await compile ( ) ;
145+ } else {
146+ throw e ;
147+ }
148+ }
149+ } ,
142150 cancelable : true ,
143151 } ) ;
144152 this . messageService . info (
Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ export namespace CoreError {
7272 UploadUsingProgrammer : 4003 ,
7373 BurnBootloader : 4004 ,
7474 UploadRequiresProgrammer : 4005 ,
75+ ClientInstanceExpired : 4006 ,
7576 } ;
7677 export const VerifyFailed = declareCoreError ( Codes . Verify ) ;
7778 export const UploadFailed = declareCoreError ( Codes . Upload ) ;
@@ -82,6 +83,9 @@ export namespace CoreError {
8283 export const UploadRequiresProgrammer = declareCoreError (
8384 Codes . UploadRequiresProgrammer
8485 ) ;
86+ export const ClientInstanceExpired = declareCoreError (
87+ Codes . ClientInstanceExpired
88+ ) ;
8589
8690 export function is (
8791 error : unknown
Original file line number Diff line number Diff line change @@ -112,6 +112,15 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
112112 reject ( UserAbortApplicationError ( ) ) ;
113113 return ;
114114 }
115+
116+ if (
117+ ServiceError . isInvalidArgument ( error ) &&
118+ error . details . includes ( 'instance is no longer valid' )
119+ ) {
120+ reject ( CoreError . ClientInstanceExpired ( ) ) ;
121+ return ;
122+ }
123+
115124 const compilerErrors = tryParseError ( {
116125 content : handler . content ,
117126 sketch : options . sketch ,
You can’t perform that action at this time.
0 commit comments