Skip to content

fix: do not show error from preview initialization when stop is called #4271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions lib/commands/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,11 @@ export class PreviewCommand implements ICommand {
this.$logger.info(message);
});

await this.$liveSyncService.liveSync([], {
syncToPreviewApp: true,
projectDir: this.$projectData.projectDir,
skipWatcher: !this.$options.watch,
watchAllFiles: this.$options.syncAllFiles,
clean: this.$options.clean,
await this.$liveSyncService.liveSyncToPreviewApp({
bundle: !!this.$options.bundle,
release: this.$options.release,
env: this.$options.env,
timeout: this.$options.timeout,
useHotModuleReload: this.$options.hmr
useHotModuleReload: this.$options.hmr,
projectDir: this.$projectData.projectDir,
env: this.$options.env
});

await this.$previewQrCodeService.printLiveSyncQrCode({ useHotModuleReload: this.$options.hmr, link: this.$options.link });
Expand Down
7 changes: 7 additions & 0 deletions lib/definitions/livesync.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ interface ILiveSyncService {
*/
liveSync(deviceDescriptors: ILiveSyncDeviceInfo[], liveSyncData: ILiveSyncInfo): Promise<void>;

/**
* Starts LiveSync operation to Preview app.
* @param {IPreviewAppLiveSyncData} data Describes information about the current operation.
* @returns {Promise<IQrCodeImageData>} Data of the QR code that should be used to start the LiveSync operation.
*/
liveSyncToPreviewApp(data: IPreviewAppLiveSyncData): Promise<IQrCodeImageData>;

/**
* Stops LiveSync operation for specified directory.
* @param {string} projectDir The directory for which to stop the operation.
Expand Down
10 changes: 6 additions & 4 deletions lib/services/livesync/livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
return currentDescriptors || [];
}

@cache()
private attachToPreviewAppLiveSyncError(): void {
this.$previewAppLiveSyncService.on(LiveSyncEvents.previewAppLiveSyncError, liveSyncData => {
this.emit(LiveSyncEvents.previewAppLiveSyncError, liveSyncData);
});
if (!this.$usbLiveSyncService.isInitialized) {
this.$previewAppLiveSyncService.on(LiveSyncEvents.previewAppLiveSyncError, liveSyncData => {
this.$logger.error(liveSyncData.error);
this.emit(LiveSyncEvents.previewAppLiveSyncError, liveSyncData);
});
}
}

private handleWarnings(liveSyncData: ILiveSyncInfo, projectData: IProjectData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class PreviewAppLiveSyncService extends EventEmitter implements IPreviewA
this.deviceInitializationPromise[device.id] = null;
}
} catch (error) {
this.$logger.error(error);
this.$logger.trace(`Error while sending files on device ${device && device.id}. Error is`, error);
this.emit(PreviewAppLiveSyncEvents.PREVIEW_APP_LIVE_SYNC_ERROR, {
error,
data,
Expand Down
4 changes: 4 additions & 0 deletions test/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,10 @@ export class DebugServiceStub extends EventEmitter implements IDeviceDebugServic
}

export class LiveSyncServiceStub implements ILiveSyncService {
public async liveSyncToPreviewApp(data: IPreviewAppLiveSyncData): Promise<IQrCodeImageData> {
return;
}

public async liveSync(deviceDescriptors: ILiveSyncDeviceInfo[], liveSyncData: ILiveSyncInfo): Promise<void> {
return;
}
Expand Down