( info: DaemonInfo, statePaths: DaemonPaths, requestId: string | undefined, command: string | undefined, remote: boolean, timeoutMs: number, )
| 18 | ]; |
| 19 | |
| 20 | export function handleRequestTimeout( |
| 21 | info: DaemonInfo, |
| 22 | statePaths: DaemonPaths, |
| 23 | requestId: string | undefined, |
| 24 | command: string | undefined, |
| 25 | remote: boolean, |
| 26 | timeoutMs: number, |
| 27 | ): AppError { |
| 28 | const cleanup = remote ? { terminated: 0 } : cleanupTimedOutIosRunnerBuilds(); |
| 29 | const resetDaemon = !remote && shouldResetDaemonAfterRequestTimeout(command); |
| 30 | const daemonReset = resetDaemon |
| 31 | ? resetDaemonAfterTimeout(info, statePaths) |
| 32 | : { forcedKill: false }; |
| 33 | emitDiagnostic({ |
| 34 | level: 'error', |
| 35 | phase: 'daemon_request_timeout', |
| 36 | data: { |
| 37 | timeoutMs, |
| 38 | requestId, |
| 39 | command, |
| 40 | timedOutRunnerPidsTerminated: cleanup.terminated, |
| 41 | timedOutRunnerCleanupError: cleanup.error, |
| 42 | daemonPidReset: resetDaemon ? info.pid : undefined, |
| 43 | daemonPidForceKilled: resetDaemon ? daemonReset.forcedKill : undefined, |
| 44 | daemonPreservedAfterTimeout: !remote && !resetDaemon, |
| 45 | daemonBaseUrl: info.baseUrl, |
| 46 | }, |
| 47 | }); |
| 48 | return new AppError('COMMAND_FAILED', 'Daemon request timed out', { |
| 49 | timeoutMs, |
| 50 | requestId, |
| 51 | hint: resolveRequestTimeoutHint({ remote, resetDaemon, command }), |
| 52 | }); |
| 53 | } |
| 54 | |
| 55 | export function shouldResetDaemonAfterRequestTimeout(command: string | undefined): boolean { |
| 56 | // Snapshot can block in platform accessibility bridges while the app is crashed or never idle. |
no test coverage detected