{"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":"error","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/3aec848f2885144aa8f1e53b9731a04310d5d558/open-computer/services/extensions/visible-bash.ts#L177-L213","documentation":"Thrown by the visible-bash extension when the caller-supplied timeout (seconds, optional parameter) elapsed before the wrapper script finished. The tool kills the command and raises this error, prefixing the last output captured (truncated to 2000 lines / 256KB) before the 'Command timed out after N seconds' suffix. Note there is no default timeout — this only fires when the timeout parameter was explicitly passed.","triggerScenarios":"Calling the bash tool with { command: 'make build', timeout: 30 } where the build takes longer than 30s; any explicitly-timed command whose real runtime exceeds the estimate (package installs, large test suites, network fetches inside the visible terminal).","commonSituations":"CI-like workloads inside the VM (apt-get upgrade, npm install) that occasionally exceed their usual duration; overly tight timeouts tuned on a warm cache then hit on a cold cache; commands that wait on interactive input and hang until the timeout.","solutions":["Re-run with a larger timeout parameter sized for the slowest realistic run (e.g. 300–600s for installs)","Split the work: launch it detached (nohup cmd > log 2>&1 & echo PID) and poll the log/exit file with short calls, avoiding the timeout entirely","If the command may be waiting for stdin, redirect </dev/null or pass the non-interactive flag so it fails fast instead of hanging to timeout"],"exampleFix":"// before\n{ \"command\": \"npm install\", \"timeout\": 30 }\n// after\n{ \"command\": \"npm install\", \"timeout\": 600 }\n// or detach and poll:\n{ \"command\": \"nohup npm install > /tmp/ni.log 2>&1 & echo $!\" }\n{ \"command\": \"tail -5 /tmp/ni.log; kill -0 $(cat /tmp/ni.pid) 2>/dev/null || echo done\" }","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { const out = await bash.run(cmd, { timeout: 120 }); } catch (e) { const m = e.message.match(/Command timed out after (\\d+) seconds/); if (m) { /* re-run with a doubled timeout only if the command is idempotent */ } else throw e; }","preventionTips":["Size timeouts from the cold-cache worst case, not the warm median (installs, first builds)","Detach long-running work (nohup + log file + PID) and poll with short, un-timed calls","Close stdin or pass non-interactive flags so prompts can't hang a command to the timeout"],"tags":["bash","timeout","process-management","open-computer"],"backgroundTag":"command-timeout","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}