{"record":{"id":"01f381a7bfcea857","repo":"ruvnet/ruflo","slug":"browser-eval-script-exceeds-maximum-length-of-m","errorCode":null,"errorMessage":"browser/eval: script exceeds maximum length of ${MAX_EVAL_SCRIPT_LENGTH} characters","messagePattern":"browser/eval: script exceeds maximum length of (.+?) characters","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/browser/src/mcp-tools/browser-tools.ts","lineNumber":671,"sourceCode":"      properties: {\n        session: { type: 'string', description: 'Session ID' },\n        script: {\n          type: 'string',\n          description: `JavaScript code to execute (max ${MAX_EVAL_SCRIPT_LENGTH} chars)`,\n          maxLength: MAX_EVAL_SCRIPT_LENGTH,\n        },\n      },\n      required: ['script'],\n    },\n    handler: async (input) => {\n      const script = input.script as string;\n\n      // Validate script length\n      if (!script || script.length === 0) {\n        throw new Error('browser/eval: script must not be empty');\n      }\n      if (script.length > MAX_EVAL_SCRIPT_LENGTH) {\n        throw new Error(`browser/eval: script exceeds maximum length of ${MAX_EVAL_SCRIPT_LENGTH} characters`);\n      }\n\n      // Check for dangerous patterns\n      for (const pattern of DANGEROUS_EVAL_PATTERNS) {\n        if (pattern.test(script)) {\n          throw new Error(`browser/eval: script contains disallowed pattern: ${pattern.source}`);\n        }\n      }\n\n      // Audit log\n      console.info(`[browser/eval] Executing script (${script.length} chars) in session ${input.session || 'default'}`);\n\n      const adapter = getAdapter(input.session as string);\n      return adapter.eval({ script });\n    },\n  },\n];\n","sourceCodeStart":653,"sourceCodeEnd":689,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/browser/src/mcp-tools/browser-tools.ts#L653-L689","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Reduce the script: load large data via a separate fetch or a <script src> rather than inlining.","If the limit is genuinely too low for your use case, raise CLAUDE_FLOW_MAX_EVAL_SCRIPT_LENGTH at process start.","Split the work into multiple smaller browser/eval calls and persist intermediate state in the page."],"exampleFix":"// before\nawait evalTool.handler({ script: hugeBundle }); // throws 63\n\n// after — raise the cap for this process, or shrink the script\n// process.env.CLAUDE_FLOW_MAX_EVAL_SCRIPT_LENGTH = '50000';\nawait evalTool.handler({ script: trimmedScript });","handlingStrategy":"validation","validationCode":"const MAX = parseInt(process.env.CLAUDE_FLOW_MAX_EVAL_SCRIPT_LENGTH || '', 10) || 20_000;\nfunction fits(script) { return typeof script === 'string' && script.length <= MAX; }","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Avoid inlining large data — load it through the page instead.","Document the CLAUDE_FLOW_MAX_EVAL_SCRIPT_LENGTH override for operators who need a higher cap.","Split oversized scripts into sequential smaller evals."],"tags":["mcp","browser-eval","limits","config","typescript"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}