@@ -144,10 +144,10 @@ export class RunController extends EventEmitter implements IRunController {
144144 return this . $liveSyncProcessDataService . getDeviceDescriptors ( data . projectDir ) ;
145145 }
146146
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 > {
148148 const result = deviceDescriptor . debuggingEnabled ?
149149 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 ) ;
151151
152152 const device = liveSyncResultInfo . deviceAppData . device ;
153153
@@ -181,14 +181,15 @@ export class RunController extends EventEmitter implements IRunController {
181181 }
182182
183183 @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 > {
185185 const result = { didRestart : false } ;
186186 const platform = liveSyncResultInfo . deviceAppData . platform ;
187187 const applicationIdentifier = projectData . projectIdentifiers [ platform . toLowerCase ( ) ] ;
188188 const platformLiveSyncService = this . $liveSyncServiceResolver . resolveLiveSyncService ( platform ) ;
189189
190190 try {
191- let shouldRestart = filesChangeEventData && ( filesChangeEventData . hasNativeChanges || ! filesChangeEventData . hasOnlyHotUpdateFiles ) ;
191+ const isFullSync = filesChangeEventData && ( filesChangeEventData . hasNativeChanges || ! filesChangeEventData . hasOnlyHotUpdateFiles ) ;
192+ let shouldRestart = isFullSync ;
192193 if ( ! shouldRestart ) {
193194 shouldRestart = await platformLiveSyncService . shouldRestart ( projectData , liveSyncResultInfo ) ;
194195 }
@@ -197,6 +198,12 @@ export class RunController extends EventEmitter implements IRunController {
197198 shouldRestart = ! await platformLiveSyncService . tryRefreshApplication ( projectData , liveSyncResultInfo ) ;
198199 }
199200
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+
200207 if ( shouldRestart ) {
201208 this . emit ( DEBUGGER_DETACHED_EVENT_NAME , { deviceIdentifier : liveSyncResultInfo . deviceAppData . device . deviceInfo . identifier } ) ;
202209 await platformLiveSyncService . restartApplication ( projectData , liveSyncResultInfo ) ;
@@ -393,16 +400,21 @@ export class RunController extends EventEmitter implements IRunController {
393400 }
394401
395402 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 ) ;
398412
399413 if ( ! liveSyncResultInfo . didRecover && isInHMRMode ) {
400414 const status = await this . $hmrStatusService . getHmrStatus ( device . deviceInfo . identifier , data . hmrData . hash ) ;
401415 // error or timeout
402416 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 ( ) ;
406418 liveSyncResultInfo . isFullSync = true ;
407419 await this . refreshApplication ( projectData , liveSyncResultInfo , data , deviceDescriptor ) ;
408420 }
0 commit comments