MCPcopy Index your code
hub / github.com/callstack/agent-device / handleRequestTimeout

Function handleRequestTimeout

src/daemon/client/daemon-client-timeout.ts:20–53  ·  view source on GitHub ↗
(
  info: DaemonInfo,
  statePaths: DaemonPaths,
  requestId: string | undefined,
  command: string | undefined,
  remote: boolean,
  timeoutMs: number,
)

Source from the content-addressed store, hash-verified

18];
19
20export 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
55export function shouldResetDaemonAfterRequestTimeout(command: string | undefined): boolean {
56 // Snapshot can block in platform accessibility bridges while the app is crashed or never idle.

Callers 2

sendSocketRequestFunction · 0.90
sendHttpRequestFunction · 0.90

Calls 5

emitDiagnosticFunction · 0.90
resetDaemonAfterTimeoutFunction · 0.85

Tested by

no test coverage detected