ruvnet/ruflo · error · Error

browser/eval: script exceeds maximum length of ${MAX_EVAL_SC

Error message

browser/eval: script exceeds maximum length of ${MAX_EVAL_SCRIPT_LENGTH} characters

What it means

Thrown by browser/eval when script.length exceeds MAX_EVAL_SCRIPT_LENGTH. That constant defaults to 20,000 chars but can be overridden via the CLAUDE_FLOW_MAX_EVAL_SCRIPT_LENGTH env var (parsed as int, falls back to default on NaN). The check runs after the empty-script check and before the dangerous-pattern scan.

Source

Thrown at v3/@claude-flow/browser/src/mcp-tools/browser-tools.ts:671

      properties: {
        session: { type: 'string', description: 'Session ID' },
        script: {
          type: 'string',
          description: `JavaScript code to execute (max ${MAX_EVAL_SCRIPT_LENGTH} chars)`,
          maxLength: MAX_EVAL_SCRIPT_LENGTH,
        },
      },
      required: ['script'],
    },
    handler: async (input) => {
      const script = input.script as string;

      // Validate script length
      if (!script || script.length === 0) {
        throw new Error('browser/eval: script must not be empty');
      }
      if (script.length > MAX_EVAL_SCRIPT_LENGTH) {
        throw new Error(`browser/eval: script exceeds maximum length of ${MAX_EVAL_SCRIPT_LENGTH} characters`);
      }

      // Check for dangerous patterns
      for (const pattern of DANGEROUS_EVAL_PATTERNS) {
        if (pattern.test(script)) {
          throw new Error(`browser/eval: script contains disallowed pattern: ${pattern.source}`);
        }
      }

      // Audit log
      console.info(`[browser/eval] Executing script (${script.length} chars) in session ${input.session || 'default'}`);

      const adapter = getAdapter(input.session as string);
      return adapter.eval({ script });
    },
  },
];

View on GitHub (pinned to 6b01dc5a68)

Solutions

  1. Reduce the script: load large data via a separate fetch or a <script src> rather than inlining.
  2. If the limit is genuinely too low for your use case, raise CLAUDE_FLOW_MAX_EVAL_SCRIPT_LENGTH at process start.
  3. Split the work into multiple smaller browser/eval calls and persist intermediate state in the page.

Example fix

// before
await evalTool.handler({ script: hugeBundle }); // throws 63

// after — raise the cap for this process, or shrink the script
// process.env.CLAUDE_FLOW_MAX_EVAL_SCRIPT_LENGTH = '50000';
await evalTool.handler({ script: trimmedScript });
Defensive patterns

Strategy: validation

Validate before calling

const MAX = parseInt(process.env.CLAUDE_FLOW_MAX_EVAL_SCRIPT_LENGTH || '', 10) || 20_000;
function fits(script) { return typeof script === 'string' && script.length <= MAX; }

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: Passing a script longer than 20,000 chars (default), or longer than a custom CLAUDE_FLOW_MAX_EVAL_SCRIPT_LENGTH. Common with minified bundles, large data literals, or templated scripts that embed JSON payloads.

Common situations: Inlining a big fixture or base64 blob into the eval script; copying a full library into the page via eval instead of a script tag; env var set very low in a locked-down deployment.

Related errors


AI-assisted analysis of ruvnet/ruflo@6b01dc5a68 (2026-08-12). Data as JSON: /api/errors/01f381a7bfcea857. Report an issue: GitHub.