{"record":{"id":"18b0354a113683f9","repo":"Mintplex-Labs/anything-llm","slug":"command-timed-out-after-timeout-seconds","errorCode":null,"errorMessage":"Command timed out after ${timeout} seconds","messagePattern":"Command timed out after (.+?) seconds","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"open-computer/services/extensions/visible-bash.ts","lineNumber":195,"sourceCode":"          output = readFileSync(outputFile, \"utf-8\");\n        } catch {}\n\n        let realExitCode = exitCode;\n        try {\n          const ecStr = readFileSync(exitCodeFile, \"utf-8\").trim();\n          if (ecStr) realExitCode = parseInt(ecStr, 10);\n        } catch {}\n\n        if (signal?.aborted) {\n          throw new Error(\n            output\n              ? `${truncateOutput(output)}\\n\\nCommand aborted`\n              : \"Command aborted\"\n          );\n        }\n\n        if (timedOut) {\n          throw new Error(\n            output\n              ? `${truncateOutput(output)}\\n\\nCommand timed out after ${timeout} seconds`\n              : `Command timed out after ${timeout} seconds`\n          );\n        }\n\n        const text = truncateOutput(output) || \"(no output)\";\n\n        if (realExitCode !== 0 && realExitCode !== null) {\n          throw new Error(`${text}\\n\\nCommand exited with code ${realExitCode}`);\n        }\n\n        return { content: [{ type: \"text\", text }], details: {} };\n      } finally {\n        cleanup();\n      }\n    },\n  });","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/open-computer/services/extensions/visible-bash.ts#L177-L213","documentation":"Thrown by visible-bash when timedOut is true: the command exceeded the configured timeout (in seconds) before completing. The thrown message includes the captured (truncated) output if any, then the timeout marker. Distinct from the abort path: timeout is wall-clock expiry, abort is explicit signal cancellation.","triggerScenarios":"Running a command that legitimately takes longer than the supplied timeout (large build, slow network fetch, interactive prompt that never returns), or a hung process waiting on stdin/a lock.","commonSituations":"npm install / pnpm build on a cold cache exceeding a 60s default; command waiting for user input in non-interactive mode; network fetch behind a slow proxy; a deadlock on a file lock.","solutions":["Increase the timeout argument passed to the tool for known long-running commands.","Run the command in the background (nohup / &) and poll its output file instead of blocking the tool.","Add non-interactive flags (--yes, CI=true, < /dev/null) so the command never blocks on stdin.","Diagnose with the truncated output in the message to see where the command stalled."],"exampleFix":"// before\nbash({ command: \"pnpm install\", timeout: 60 });\n\n// after\nbash({ command: \"pnpm install\", timeout: 600 });","handlingStrategy":"validation","validationCode":"// Sanity-check that the timeout exceeds the command's expected runtime.\nfunction adequateTimeout(cmd, timeout) {\n  const known = { 'pnpm install': 600, build: 600, test: 300 };\n  for (const k of Object.keys(known)) if (cmd.includes(k)) return timeout >= known[k];\n  return timeout >= 60;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await bash({ command, timeout });\n} catch (e) {\n  if (/Command timed out/.test(e.message)) {\n    // e.message includes partial output; decide to retry with a larger timeout or background it\n  }\n  throw e;\n}","preventionTips":["Pass non-interactive flags (< /dev/null, --yes, CI=true) so commands never block on stdin.","Use generous timeouts for known-slow commands (install, build).","Background long-running commands and poll their output file."],"tags":["mcp-tool","shell","timeout","visible-bash","process-control"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}