File tree 3 files changed +29
-8
lines changed
arduino-ide-extension/src
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 {
131
131
'arduino/sketch/compile' ,
132
132
'Compiling sketch...'
133
133
) ,
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
+ } ,
142
150
cancelable : true ,
143
151
} ) ;
144
152
this . messageService . info (
Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ export namespace CoreError {
72
72
UploadUsingProgrammer : 4003 ,
73
73
BurnBootloader : 4004 ,
74
74
UploadRequiresProgrammer : 4005 ,
75
+ ClientInstanceExpired : 4006 ,
75
76
} ;
76
77
export const VerifyFailed = declareCoreError ( Codes . Verify ) ;
77
78
export const UploadFailed = declareCoreError ( Codes . Upload ) ;
@@ -82,6 +83,9 @@ export namespace CoreError {
82
83
export const UploadRequiresProgrammer = declareCoreError (
83
84
Codes . UploadRequiresProgrammer
84
85
) ;
86
+ export const ClientInstanceExpired = declareCoreError (
87
+ Codes . ClientInstanceExpired
88
+ ) ;
85
89
86
90
export function is (
87
91
error : unknown
Original file line number Diff line number Diff line change @@ -112,6 +112,15 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
112
112
reject ( UserAbortApplicationError ( ) ) ;
113
113
return ;
114
114
}
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
+
115
124
const compilerErrors = tryParseError ( {
116
125
content : handler . content ,
117
126
sketch : options . sketch ,
You can’t perform that action at this time.
0 commit comments