From 89dd3aa63344566263b58b852adb79af67ca4174 Mon Sep 17 00:00:00 2001 From: fatme Date: Wed, 2 Jan 2019 11:54:50 +0200 Subject: [PATCH 1/2] fix: fix unhandled promise rejection error thrown from sidekick --- .../preview-app-livesync-service.ts | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/services/livesync/playground/preview-app-livesync-service.ts b/lib/services/livesync/playground/preview-app-livesync-service.ts index ed0780cc75..062562f793 100644 --- a/lib/services/livesync/playground/preview-app-livesync-service.ts +++ b/lib/services/livesync/playground/preview-app-livesync-service.ts @@ -26,20 +26,25 @@ export class PreviewAppLiveSyncService extends EventEmitter implements IPreviewA public async initialize(data: IPreviewAppLiveSyncData): Promise { 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 (err) { + this.$logger.error(err); + this.emit(PreviewAppLiveSyncEvents.PREVIEW_APP_LIVE_SYNC_ERROR, err); } }); } From 4db5bb39f45d607a60a082cb7d7c7fdef937ee83 Mon Sep 17 00:00:00 2001 From: fatme Date: Wed, 2 Jan 2019 17:05:09 +0200 Subject: [PATCH 2/2] chore: emit correctly PREVIEW_APP_LIVE_SYNC_ERROR --- .../playground/preview-app-livesync-service.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/services/livesync/playground/preview-app-livesync-service.ts b/lib/services/livesync/playground/preview-app-livesync-service.ts index 062562f793..4dae4f41e8 100644 --- a/lib/services/livesync/playground/preview-app-livesync-service.ts +++ b/lib/services/livesync/playground/preview-app-livesync-service.ts @@ -42,9 +42,14 @@ export class PreviewAppLiveSyncService extends EventEmitter implements IPreviewA } finally { this.deviceInitializationPromise[device.id] = null; } - } catch (err) { - this.$logger.error(err); - this.emit(PreviewAppLiveSyncEvents.PREVIEW_APP_LIVE_SYNC_ERROR, err); + } catch (error) { + this.$logger.error(error); + this.emit(PreviewAppLiveSyncEvents.PREVIEW_APP_LIVE_SYNC_ERROR, { + error, + data, + platform: device.platform, + deviceId: device.id + }); } }); }