@@ -20,6 +20,9 @@ export class MonitorManager extends CoreClientAware {
20
20
// If either the board or port managed changes, a new service must
21
21
// be started.
22
22
private monitorServices = new Map < MonitorID , MonitorService > ( ) ;
23
+ private isUploadInProgress : boolean ;
24
+
25
+ private startMonitorPendingRequests : Array < MonitorID > = [ ] ;
23
26
24
27
@inject ( MonitorServiceFactory )
25
28
private monitorServiceFactory : MonitorServiceFactory ;
@@ -62,7 +65,11 @@ export class MonitorManager extends CoreClientAware {
62
65
if ( ! monitor ) {
63
66
monitor = this . createMonitor ( board , port ) ;
64
67
}
65
- return await monitor . start ( ) ;
68
+ if ( this . isUploadInProgress ) {
69
+ this . startMonitorPendingRequests . push ( monitorID ) ;
70
+ return Status . UPLOAD_IN_PROGRESS ;
71
+ }
72
+ return monitor . start ( ) ;
66
73
}
67
74
68
75
/**
@@ -117,7 +124,7 @@ export class MonitorManager extends CoreClientAware {
117
124
// There's no monitor running there, bail
118
125
return ;
119
126
}
120
- monitor . setUploadInProgress ( true ) ;
127
+ this . isUploadInProgress = true ;
121
128
return await monitor . pause ( ) ;
122
129
}
123
130
@@ -130,6 +137,14 @@ export class MonitorManager extends CoreClientAware {
130
137
* started or if there have been errors.
131
138
*/
132
139
async notifyUploadFinished ( board ?: Board , port ?: Port ) : Promise < Status > {
140
+ try {
141
+ for ( const id of this . startMonitorPendingRequests ) {
142
+ const m = this . monitorServices . get ( id ) ;
143
+ if ( m ) m . start ( ) ;
144
+ }
145
+ } finally {
146
+ this . startMonitorPendingRequests = [ ] ;
147
+ }
133
148
if ( ! board || ! port ) {
134
149
// We have no way of knowing which monitor
135
150
// to retrieve if we don't have this information.
@@ -141,8 +156,9 @@ export class MonitorManager extends CoreClientAware {
141
156
// There's no monitor running there, bail
142
157
return Status . NOT_CONNECTED ;
143
158
}
144
- monitor . setUploadInProgress ( false ) ;
145
- return await monitor . start ( ) ;
159
+ this . isUploadInProgress = false ;
160
+
161
+ return monitor . start ( ) ;
146
162
}
147
163
148
164
/**
0 commit comments