From 4928df08e2a3a94b95ee786b7c9b0430a39512f5 Mon Sep 17 00:00:00 2001 From: Mo Date: Mon, 24 Oct 2022 08:33:24 -0500 Subject: [PATCH] fix: prevent duplicate launch calls (#1867) --- packages/snjs/lib/Application/Application.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/snjs/lib/Application/Application.ts b/packages/snjs/lib/Application/Application.ts index aca04f2c1..99e89d454 100644 --- a/packages/snjs/lib/Application/Application.ts +++ b/packages/snjs/lib/Application/Application.ts @@ -284,6 +284,10 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli * This function will load all services in their correct order. */ async prepareForLaunch(callback: LaunchCallback): Promise { + if (this.launched) { + throw new Error('Attempting to prelaunch already launched application') + } + await this.options.crypto.initialize() this.setLaunchCallback(callback) @@ -323,6 +327,10 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli * Option to await database load before marking the app as ready. */ public async launch(awaitDatabaseLoad = false): Promise { + if (this.launched) { + throw new Error('Attempting to launch already launched application') + } + this.launched = false const launchChallenge = this.getLaunchChallenge()