diff --git a/packages/app/src/cli/services/dev/processes/dev-session.ts b/packages/app/src/cli/services/dev/processes/dev-session.ts index 59022d3731..12553f89d3 100644 --- a/packages/app/src/cli/services/dev/processes/dev-session.ts +++ b/packages/app/src/cli/services/dev/processes/dev-session.ts @@ -47,7 +47,7 @@ let bundleControllers: AbortController[] = [] // Current status of the dev session // Since the watcher can emit events before the dev session is ready, we need to keep track of the status -let devSessionStatus: 'starting' | 'ready' = 'starting' +let isDevSessionReady = false export async function setupDevSessionProcess({ app, @@ -89,7 +89,7 @@ export const pushUpdatesForDevSession: DevProcessFunction = a appWatcher .onEvent(async (event) => { - if (devSessionStatus !== 'ready') { + if (!isDevSessionReady) { await printWarning('Change detected, but dev session is not ready yet.', processOptions.stdout) return } @@ -131,7 +131,7 @@ export const pushUpdatesForDevSession: DevProcessFunction = a // utility to debug issues with the dev API. function startTimeout(processOptions: DevSessionProcessOptions) { setTimeout(() => { - if (devSessionStatus !== 'ready') { + if (!isDevSessionReady) { printError('❌ Timeout, session failed to start in 30s, please try again.', processOptions.stdout).catch(() => {}) process.exit(1) } @@ -216,14 +216,14 @@ async function bundleExtensionsAndUpload(options: DevSessionProcessOptions): Pro // Create or update the dev session if (currentBundleController.signal.aborted) return {status: 'aborted'} try { - if (devSessionStatus === 'ready') { + if (isDevSessionReady) { await options.developerPlatformClient.devSessionUpdate(payload) return {status: 'updated'} } else { startTimeout(options) await options.developerPlatformClient.devSessionCreate(payload) // eslint-disable-next-line require-atomic-updates - devSessionStatus = 'ready' + isDevSessionReady = true return {status: 'created'} } // eslint-disable-next-line @typescript-eslint/no-explicit-any