Skip to content

Commit

Permalink
use a boolean instead of an enum
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacroldan committed Nov 13, 2024
1 parent 634a11d commit c1c1cdc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/app/src/cli/services/dev/processes/dev-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -89,7 +89,7 @@ export const pushUpdatesForDevSession: DevProcessFunction<DevSessionOptions> = a

appWatcher
.onEvent(async (event) => {
if (devSessionStatus !== 'ready') {
if (!isDevSessionReady) {
await printWarning('Change detected, but dev session is not ready yet.', processOptions.stdout)
return
}
Expand Down Expand Up @@ -131,7 +131,7 @@ export const pushUpdatesForDevSession: DevProcessFunction<DevSessionOptions> = 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)
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c1c1cdc

Please sign in to comment.