Repository: cypress-io/cypress
File: packages/server/lib/socket-base.ts (TypeScript)

Code before:
            }
          }

          return Bluebird.try(backendRequest)
          .then((resp) => {
            return cb({ response: resp })
          }).catch((err) => {
            return cb({ error: errors.cloneErr(err) })
          })
        })

        socket.on('get:cached:test:state', async (cb: (runState: RunState | null, testState: CachedTestState) => void) => {
          const s = runState

          const cachedTestState: CachedTestState = {
            activeSessions: session.getActiveSessions(),
          }

          if (s) {
            runState = undefined

            // if we have cached test state, then we need to reset
            // the test state on the protocol manager and prompt manager
            if (s.currentId) {
              const testId = s.currentId
              const currentRetry = s.currentRetry

              this._protocolManager?.resetTest(testId, currentRetry)

              try {
                const cyPrompt = await getCtx().coreData.cyPromptLifecycleManager?.getCyPrompt()

                // reset the prompt manager for the current test to clear any
                // cached state when top changes for the current test
                cyPrompt?.cyPromptManager?.reset(testId)
              } catch (error) {
                debug('error resetting prompt manager', error)
              }
            }
          }

          return cb(s || {}, cachedTestState)
        })

        socket.on('get:app:state', async (opts, cb) => {
          try {
            const state = await options.getSavedState(opts)

            cb({ data: state })
          } catch (error) {
            cb({ error: errors.cloneErr(error) })

Review comment (suggestion):
```suggestion
              const currentRetry = s.currentRetry ?? undefined
```

Code after:
            }
          }

          return Bluebird.try(backendRequest)
          .then((resp) => {
            return cb({ response: resp })
          }).catch((err) => {
            return cb({ error: errors.cloneErr(err) })
          })
        })

        socket.on('get:cached:test:state', async (cb: (runState: RunState | null, testState: CachedTestState) => void) => {
          const s = runState

          const cachedTestState: CachedTestState = {
            activeSessions: session.getActiveSessions(),
          }

          if (s) {
            runState = undefined

            // if we have cached test state, then we need to reset
            // the test state on the protocol manager and prompt manager
            if (s.currentId) {
              const testId = s.currentId
              const currentRetry = s.currentRetry ?? undefined

              this._protocolManager?.resetTest(testId, currentRetry)

              try {
                const cyPrompt = await getCtx().coreData.cyPromptLifecycleManager?.getCyPrompt()

                // reset the prompt manager for the current test to clear any
                // cached state when top changes for the current test
                cyPrompt?.cyPromptManager?.reset(testId)
              } catch (error) {
                debug('error resetting prompt manager', error)
              }
            }
          }

          return cb(s || {}, cachedTestState)
        })

        socket.on('get:app:state', async (opts, cb) => {
          try {
            const state = await options.getSavedState(opts)

            cb({ data: state })
          } catch (error) {
            cb({ error: errors.cloneErr(error) })