Skip to content
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

fix: fix unhandled promise rejection error from sidekick when livesync to preview app with bundle #4251

Merged
merged 2 commits into from
Jan 3, 2019
Merged
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
34 changes: 22 additions & 12 deletions lib/services/livesync/playground/preview-app-livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,30 @@ export class PreviewAppLiveSyncService extends EventEmitter implements IPreviewA

public async initialize(data: IPreviewAppLiveSyncData): Promise<void> {
await this.$previewSdkService.initialize(async (device: Device) => {
if (!device) {
this.$errors.failWithoutHelp("Sending initial preview files without a specified device is not supported.");
}
try {
if (!device) {
this.$errors.failWithoutHelp("Sending initial preview files without a specified device is not supported.");
}

if (this.deviceInitializationPromise[device.id]) {
return this.deviceInitializationPromise[device.id];
}
if (this.deviceInitializationPromise[device.id]) {
return this.deviceInitializationPromise[device.id];
}

this.deviceInitializationPromise[device.id] = this.getInitialFilesForDevice(data, device);
try {
const payloads = await this.deviceInitializationPromise[device.id];
return payloads;
} finally {
this.deviceInitializationPromise[device.id] = null;
this.deviceInitializationPromise[device.id] = this.getInitialFilesForDevice(data, device);
try {
const payloads = await this.deviceInitializationPromise[device.id];
return payloads;
} finally {
this.deviceInitializationPromise[device.id] = null;
}
} catch (error) {
this.$logger.error(error);
this.emit(PreviewAppLiveSyncEvents.PREVIEW_APP_LIVE_SYNC_ERROR, {
error,
data,
platform: device.platform,
deviceId: device.id
});
}
});
}
Expand Down