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

Function classifyBootFailure

src/platforms/boot-diagnostics.ts:31–124  ·  view source on GitHub ↗
(input: {
  error?: unknown;
  message?: string;
  stdout?: string;
  stderr?: string;
  context?: BootDiagnosticContext;
})

Source from the content-addressed store, hash-verified

29}
30
31export function classifyBootFailure(input: {
32 error?: unknown;
33 message?: string;
34 stdout?: string;
35 stderr?: string;
36 context?: BootDiagnosticContext;
37}): BootFailureReason {
38 const appErr = input.error ? asAppError(input.error) : null;
39 const platform = input.context?.platform;
40 const phase = input.context?.phase;
41 if (appErr?.code === 'TOOL_MISSING') {
42 return platform === 'android' ? 'ADB_TRANSPORT_UNAVAILABLE' : 'IOS_TOOL_MISSING';
43 }
44 const details = (appErr?.details ?? {}) as Record<string, unknown>;
45 const detailMessage = typeof details.message === 'string' ? details.message : undefined;
46 const detailStdout = typeof details.stdout === 'string' ? details.stdout : undefined;
47 const detailStderr = typeof details.stderr === 'string' ? details.stderr : undefined;
48 const nestedBoot =
49 details.boot && typeof details.boot === 'object'
50 ? (details.boot as Record<string, unknown>)
51 : null;
52 const nestedBootstatus =
53 details.bootstatus && typeof details.bootstatus === 'object'
54 ? (details.bootstatus as Record<string, unknown>)
55 : null;
56
57 const haystack = [
58 input.message,
59 appErr?.message,
60 input.stdout,
61 input.stderr,
62 detailMessage,
63 detailStdout,
64 detailStderr,
65 typeof nestedBoot?.stdout === 'string' ? nestedBoot.stdout : undefined,
66 typeof nestedBoot?.stderr === 'string' ? nestedBoot.stderr : undefined,
67 typeof nestedBootstatus?.stdout === 'string' ? nestedBootstatus.stdout : undefined,
68 typeof nestedBootstatus?.stderr === 'string' ? nestedBootstatus.stderr : undefined,
69 ]
70 .filter(Boolean)
71 .join('\n')
72 .toLowerCase();
73
74 if (
75 platform === 'ios' &&
76 (haystack.includes('runner did not accept connection') ||
77 (phase === 'connect' &&
78 (haystack.includes('timed out') ||
79 haystack.includes('timeout') ||
80 haystack.includes('econnrefused') ||
81 haystack.includes('connection refused') ||
82 haystack.includes('fetch failed') ||
83 haystack.includes('socket hang up'))))
84 ) {
85 return 'IOS_RUNNER_CONNECT_TIMEOUT';
86 }
87 if (
88 platform === 'ios' &&

Callers 6

waitForAndroidBootFunction · 0.90
ensureBootedSimulatorFunction · 0.90
postCommandViaSimulatorFunction · 0.90
buildRunnerConnectErrorFunction · 0.90

Calls 1

asAppErrorFunction · 0.90

Tested by

no test coverage detected