Mintplex-Labs/anything-llm · error · Error

Command timed out after

Error message

Command timed out after ${timeout} seconds

What it means

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.

Solutions

  1. Re-run with a larger timeout parameter sized for the slowest realistic run (e.g. 300–600s for installs)
  2. 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
  3. 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

Example fix

// before
{ "command": "npm install", "timeout": 30 }
// after
{ "command": "npm install", "timeout": 600 }
// or detach and poll:
{ "command": "nohup npm install > /tmp/ni.log 2>&1 & echo $!" }
{ "command": "tail -5 /tmp/ni.log; kill -0 $(cat /tmp/ni.pid) 2>/dev/null || echo done" }
Defensive patterns

Strategy: retry

Try / catch

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; }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/18b0354a113683f9. Report an issue: GitHub.

Appendix: source

Thrown at open-computer/services/extensions/visible-bash.ts:195

          output = readFileSync(outputFile, "utf-8");
        } catch {}

        let realExitCode = exitCode;
        try {
          const ecStr = readFileSync(exitCodeFile, "utf-8").trim();
          if (ecStr) realExitCode = parseInt(ecStr, 10);
        } catch {}

        if (signal?.aborted) {
          throw new Error(
            output
              ? `${truncateOutput(output)}\n\nCommand aborted`
              : "Command aborted"
          );
        }

        if (timedOut) {
          throw new Error(
            output
              ? `${truncateOutput(output)}\n\nCommand timed out after ${timeout} seconds`
              : `Command timed out after ${timeout} seconds`
          );
        }

        const text = truncateOutput(output) || "(no output)";

        if (realExitCode !== 0 && realExitCode !== null) {
          throw new Error(`${text}\n\nCommand exited with code ${realExitCode}`);
        }

        return { content: [{ type: "text", text }], details: {} };
      } finally {
        cleanup();
      }
    },
  });

View on GitHub (pinned to 3aec848f28)