Skip to content

Commit 7c83e3c

Browse files
fix: stopPreview does not stop running webpack compilers
`stopPreview` method does not stop running webpack compilers, so it is no longer possible to run the same application on device (no matter preview, build or run). This happens in long living processes, like Sidekick. To fix this, add new parameter to the method - an object containing the projectDir and use it to stop the processes.
1 parent f0e79b3 commit 7c83e3c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/controllers/preview-app-controller.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon
1515

1616
constructor(
1717
private $analyticsService: IAnalyticsService,
18+
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
1819
private $errors: IErrors,
1920
private $hmrStatusService: IHmrStatusService,
2021
private $logger: ILogger,
@@ -39,9 +40,13 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon
3940
return result;
4041
}
4142

42-
public async stopPreview(): Promise<void> {
43+
public async stopPreview(data: IProjectDir): Promise<void> {
4344
this.$previewSdkService.stop();
4445
this.$previewDevicesService.updateConnectedDevices([]);
46+
47+
await this.$prepareController.stopWatchers(data.projectDir, this.$devicePlatformsConstants.Android);
48+
await this.$prepareController.stopWatchers(data.projectDir, this.$devicePlatformsConstants.iOS);
49+
4550
if (this.prepareReadyEventHandler) {
4651
this.$prepareController.removeListener(PREPARE_READY_EVENT_NAME, this.prepareReadyEventHandler);
4752
this.prepareReadyEventHandler = null;

lib/definitions/preview-app-livesync.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ declare global {
7777

7878
interface IPreviewAppController {
7979
startPreview(data: IPreviewAppLiveSyncData): Promise<IQrCodeImageData>;
80-
stopPreview(): Promise<void>;
80+
stopPreview(data: IProjectDir): Promise<void>;
8181
}
8282
}

0 commit comments

Comments
 (0)