@@ -144,10 +144,10 @@ export class RunController extends EventEmitter implements IRunController {
144
144
return this . $liveSyncProcessDataService . getDeviceDescriptors ( data . projectDir ) ;
145
145
}
146
146
147
- protected async refreshApplication ( projectData : IProjectData , liveSyncResultInfo : ILiveSyncResultInfo , filesChangeEventData : IFilesChangeEventData , deviceDescriptor : ILiveSyncDeviceDescriptor ) : Promise < IRestartApplicationInfo > {
147
+ protected async refreshApplication ( projectData : IProjectData , liveSyncResultInfo : ILiveSyncResultInfo , filesChangeEventData : IFilesChangeEventData , deviceDescriptor : ILiveSyncDeviceDescriptor , fullSyncAction ?: ( ) => Promise < void > ) : Promise < IRestartApplicationInfo > {
148
148
const result = deviceDescriptor . debuggingEnabled ?
149
149
await this . refreshApplicationWithDebug ( projectData , liveSyncResultInfo , filesChangeEventData , deviceDescriptor ) :
150
- await this . refreshApplicationWithoutDebug ( projectData , liveSyncResultInfo , filesChangeEventData , deviceDescriptor ) ;
150
+ await this . refreshApplicationWithoutDebug ( projectData , liveSyncResultInfo , filesChangeEventData , deviceDescriptor , undefined , fullSyncAction ) ;
151
151
152
152
const device = liveSyncResultInfo . deviceAppData . device ;
153
153
@@ -181,14 +181,15 @@ export class RunController extends EventEmitter implements IRunController {
181
181
}
182
182
183
183
@performanceLog ( )
184
- protected async refreshApplicationWithoutDebug ( projectData : IProjectData , liveSyncResultInfo : ILiveSyncResultInfo , filesChangeEventData : IFilesChangeEventData , deviceDescriptor : ILiveSyncDeviceDescriptor , settings ?: IRefreshApplicationSettings ) : Promise < IRestartApplicationInfo > {
184
+ protected async refreshApplicationWithoutDebug ( projectData : IProjectData , liveSyncResultInfo : ILiveSyncResultInfo , filesChangeEventData : IFilesChangeEventData , deviceDescriptor : ILiveSyncDeviceDescriptor , settings ?: IRefreshApplicationSettings , fullSyncAction ?: ( ) => Promise < void > ) : Promise < IRestartApplicationInfo > {
185
185
const result = { didRestart : false } ;
186
186
const platform = liveSyncResultInfo . deviceAppData . platform ;
187
187
const applicationIdentifier = projectData . projectIdentifiers [ platform . toLowerCase ( ) ] ;
188
188
const platformLiveSyncService = this . $liveSyncServiceResolver . resolveLiveSyncService ( platform ) ;
189
189
190
190
try {
191
- let shouldRestart = filesChangeEventData && ( filesChangeEventData . hasNativeChanges || ! filesChangeEventData . hasOnlyHotUpdateFiles ) ;
191
+ const isFullSync = filesChangeEventData && ( filesChangeEventData . hasNativeChanges || ! filesChangeEventData . hasOnlyHotUpdateFiles ) ;
192
+ let shouldRestart = isFullSync ;
192
193
if ( ! shouldRestart ) {
193
194
shouldRestart = await platformLiveSyncService . shouldRestart ( projectData , liveSyncResultInfo ) ;
194
195
}
@@ -197,6 +198,12 @@ export class RunController extends EventEmitter implements IRunController {
197
198
shouldRestart = ! await platformLiveSyncService . tryRefreshApplication ( projectData , liveSyncResultInfo ) ;
198
199
}
199
200
201
+ if ( ! isFullSync && shouldRestart && fullSyncAction ) {
202
+ this . $logger . trace ( `Syncing all files as the current app state does not support hot updates.` ) ;
203
+ liveSyncResultInfo . didRecover = true ;
204
+ await fullSyncAction ( ) ;
205
+ }
206
+
200
207
if ( shouldRestart ) {
201
208
this . emit ( DEBUGGER_DETACHED_EVENT_NAME , { deviceIdentifier : liveSyncResultInfo . deviceAppData . device . deviceInfo . identifier } ) ;
202
209
await platformLiveSyncService . restartApplication ( projectData , liveSyncResultInfo ) ;
@@ -393,16 +400,21 @@ export class RunController extends EventEmitter implements IRunController {
393
400
}
394
401
395
402
const watchAction = async ( ) : Promise < void > => {
396
- let liveSyncResultInfo = await platformLiveSyncService . liveSyncWatchAction ( device , watchInfo ) ;
397
- await this . refreshApplication ( projectData , liveSyncResultInfo , data , deviceDescriptor ) ;
403
+ const liveSyncResultInfo = await platformLiveSyncService . liveSyncWatchAction ( device , watchInfo ) ;
404
+ const fullSyncAction = async ( ) => {
405
+ watchInfo . filesToSync = allAppFiles ;
406
+ const fullLiveSyncResultInfo = await platformLiveSyncService . liveSyncWatchAction ( device , watchInfo ) ;
407
+ // IMPORTANT: keep the same instance as we rely on side effects
408
+ _ . assign ( liveSyncResultInfo , fullLiveSyncResultInfo ) ;
409
+ } ;
410
+
411
+ await this . refreshApplication ( projectData , liveSyncResultInfo , data , deviceDescriptor , fullSyncAction ) ;
398
412
399
413
if ( ! liveSyncResultInfo . didRecover && isInHMRMode ) {
400
414
const status = await this . $hmrStatusService . getHmrStatus ( device . deviceInfo . identifier , data . hmrData . hash ) ;
401
415
// error or timeout
402
416
if ( status !== HmrConstants . HMR_SUCCESS_STATUS ) {
403
- watchInfo . filesToSync = data . hmrData . fallbackFiles ;
404
- liveSyncResultInfo = await platformLiveSyncService . liveSyncWatchAction ( device , watchInfo ) ;
405
- // We want to force a restart of the application.
417
+ await fullSyncAction ( ) ;
406
418
liveSyncResultInfo . isFullSync = true ;
407
419
await this . refreshApplication ( projectData , liveSyncResultInfo , data , deviceDescriptor ) ;
408
420
}
0 commit comments