Mintplex-Labs/anything-llm · warning · Error

Command timed out after ${timeout} seconds

Error message

Command timed out after ${timeout} seconds

What it means

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.

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 526360e320)

Solutions

  1. Increase the timeout argument passed to the tool for known long-running commands.
  2. Run the command in the background (nohup / &) and poll its output file instead of blocking the tool.
  3. Add non-interactive flags (--yes, CI=true, < /dev/null) so the command never blocks on stdin.
  4. Diagnose with the truncated output in the message to see where the command stalled.

Example fix

// before
bash({ command: "pnpm install", timeout: 60 });

// after
bash({ command: "pnpm install", timeout: 600 });
Defensive patterns

Strategy: validation

Validate before calling

// Sanity-check that the timeout exceeds the command's expected runtime.
function adequateTimeout(cmd, timeout) {
  const known = { 'pnpm install': 600, build: 600, test: 300 };
  for (const k of Object.keys(known)) if (cmd.includes(k)) return timeout >= known[k];
  return timeout >= 60;
}

Try / catch

try {
  await bash({ command, timeout });
} catch (e) {
  if (/Command timed out/.test(e.message)) {
    // e.message includes partial output; decide to retry with a larger timeout or background it
  }
  throw e;
}

Prevention

When it happens

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

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

Understand the failure class

Related errors


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