Repository: cypress-io/cypress
File: packages/driver/src/cy/commands/prompt/index.ts (TypeScript)

Code before:
    return {
      error,
      bundle: undefined,
      timedOut: false,
    }
  }
}

export default (Commands: Cypress.Cypress['Commands'], Cypress: Cypress.Cypress, cy: Cypress.Cypress['cy']) => {
  // @ts-expect-error - these types are not yet implemented until the prompt command is rolled out
  if (Cypress.config('experimentalPromptCommand')) {
    let initializeCloudCyPromptPromise = initializeCloudCyPrompt(Cypress, cy)

    const commands = {
      prompt (steps: string[], commandOptions: object = {}) {
        const promptCmd = cy.state('current')

        const downloadTimeout = '_downloadTimeout' in commandOptions ? commandOptions._downloadTimeout as number : 45000

        let timeoutId: NodeJS.Timeout
        const timeoutPromise = new Promise((resolve) => {
          timeoutId = setTimeout(() => {
            resolve({
              timedOut: true,
            })
          }, downloadTimeout)
        })
        const raceBundleResult = Promise.race([
          initializeCloudCyPromptPromise,
          timeoutPromise,
        ]).finally(() => {
          clearTimeout(timeoutId)
        }) as Promise<BundleResult>

        return cy.wrap(raceBundleResult, { log: false, timeout: 1e9 }).then((bundleResult: BundleResult) => {
          if (bundleResult.timedOut) {
            cy.state('current', promptCmd)

            return $errUtils.throwErrByPath('prompt.promptDownloadTimedOut', {
              args: {
                error: new Error('cy.prompt bundle download timed out'),
              },
            })
          }

          if (bundleResult.error) {
            cy.state('current', promptCmd)
            throw bundleResult.error
          }

          const cyPrompt = bundleResult.bundle

Review comment (suggestion):
```suggestion
            resolve({
              error: undefined,
              timedOut: true,
            })
```

Code after:
    return {
      error,
      bundle: undefined,
      timedOut: false,
    }
  }
}

export default (Commands: Cypress.Cypress['Commands'], Cypress: Cypress.Cypress, cy: Cypress.Cypress['cy']) => {
  // @ts-expect-error - these types are not yet implemented until the prompt command is rolled out
  if (Cypress.config('experimentalPromptCommand')) {
    let initializeCloudCyPromptPromise = initializeCloudCyPrompt(Cypress, cy)

    const commands = {
      prompt (steps: string[], commandOptions: object = {}) {
        const promptCmd = cy.state('current')

        const downloadTimeout = '_downloadTimeout' in commandOptions ? commandOptions._downloadTimeout as number : 45000

        let timeoutId: NodeJS.Timeout
        const timeoutPromise = new Promise((resolve) => {
          timeoutId = setTimeout(() => {
            resolve({
              error: undefined,
              timedOut: true,
            })
          }, downloadTimeout)
        })
        const raceBundleResult = Promise.race([
          initializeCloudCyPromptPromise,
          timeoutPromise,
        ]).finally(() => {
          clearTimeout(timeoutId)
        }) as Promise<BundleResult>

        return cy.wrap(raceBundleResult, { log: false, timeout: 1e9 }).then((bundleResult: BundleResult) => {
          if (bundleResult.timedOut) {
            cy.state('current', promptCmd)

            return $errUtils.throwErrByPath('prompt.promptDownloadTimedOut', {
              args: {
                error: new Error('cy.prompt bundle download timed out'),
              },
            })
          }

          if (bundleResult.error) {
            cy.state('current', promptCmd)
            throw bundleResult.error
          }