Skip to content

Commit d8d2f40

Browse files
author
Fatme
authored
Merge pull request #4210 from NativeScript/fatme/fix-max-listeners-exceeded
fix: fix "MaxEventListeners detected" error when livesync is started more than 11 times from sidekick
2 parents 96a1f8a + bb36afd commit d8d2f40

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

lib/services/livesync/livesync-service.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
5656
}
5757

5858
public async liveSyncToPreviewApp(data: IPreviewAppLiveSyncData): Promise<IQrCodeImageData> {
59-
this.$previewAppLiveSyncService.on(LiveSyncEvents.previewAppLiveSyncError, liveSyncData => {
60-
this.emit(LiveSyncEvents.previewAppLiveSyncError, liveSyncData);
61-
});
59+
this.attachToPreviewAppLiveSyncError();
6260

6361
await this.liveSync([], {
6462
syncToPreviewApp: true,
@@ -139,6 +137,13 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
139137
return currentDescriptors || [];
140138
}
141139

140+
@cache()
141+
private attachToPreviewAppLiveSyncError(): void {
142+
this.$previewAppLiveSyncService.on(LiveSyncEvents.previewAppLiveSyncError, liveSyncData => {
143+
this.emit(LiveSyncEvents.previewAppLiveSyncError, liveSyncData);
144+
});
145+
}
146+
142147
private handleWarnings(liveSyncData: ILiveSyncInfo, projectData: IProjectData) {
143148
if (liveSyncData.useHotModuleReload) {
144149
this.$logger.warn("Hot Module Replacement (HMR) is currently in Beta. For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398");

npm-shrinkwrap.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"mkdirp": "0.5.1",
6060
"mute-stream": "0.0.5",
6161
"nativescript-doctor": "1.8.1",
62-
"nativescript-preview-sdk": "0.3.1",
62+
"nativescript-preview-sdk": "0.3.2",
6363
"open": "0.0.5",
6464
"ora": "2.0.0",
6565
"osenv": "0.1.3",

0 commit comments

Comments
 (0)