{"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":"exception","errorClass":null,"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/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/browser/src/mcp-tools/browser-tools.ts#L653-L689","documentation":"Thrown by the browser/eval MCP tool handler when the submitted script exceeds MAX_EVAL_SCRIPT_LENGTH characters. The limit defaults to 20,000 and can be overridden via the CLAUDE_FLOW_MAX_EVAL_SCRIPT_LENGTH environment variable (parsed at module load). The JSON schema also declares maxLength, but this handler-level check is what enforces it deterministically.","triggerScenarios":"Submitting a script longer than 20,000 chars with the default limit; setting CLAUDE_FLOW_MAX_EVAL_SCRIPT_LENGTH lower (e.g. 1000) and then sending previously-accepted scripts; inlining large data blobs or base64 payloads into the script body.","commonSituations":"Generated scripts that embed scraped page data inline; minified bundles pasted as eval scripts; teams tightening the env limit for security after scripts were already written against the default.","solutions":["Split the work into multiple smaller browser/eval calls that each stay under the limit","Move large data out of the script: fetch/derive the data inside the page or via other tools instead of inlining it","Raise the limit deliberately via CLAUDE_FLOW_MAX_EVAL_SCRIPT_LENGTH=<n> on the server process if the workload genuinely needs longer scripts (note: it is read once at startup)"],"exampleFix":"// before\nawait tools.invoke('browser/eval', { script: hugeMinifiedBundle }); // > 20000 chars\n\n// after\nfor (const chunk of splitScript(hugeMinifiedBundle, 19000)) {\n  await tools.invoke('browser/eval', { script: chunk });\n}\n// or raise the cap for the server process:\n// CLAUDE_FLOW_MAX_EVAL_SCRIPT_LENGTH=50000 node server.js","handlingStrategy":"validation","validationCode":"const MAX = Number(process.env.CLAUDE_FLOW_MAX_EVAL_SCRIPT_LENGTH) || 20000;\nif (script.length > MAX) {\n  const chunks = splitScript(script, MAX - 1000);\n  for (const c of chunks) await tools.invoke('browser/eval', { script: c });\n} else {\n  await tools.invoke('browser/eval', { script });\n}","typeGuard":null,"tryCatchPattern":"try { await tools.invoke('browser/eval', { script }); } catch (e) { if (e instanceof Error && e.message.includes('exceeds maximum length')) { await runInChunks(script); } else throw e; }","preventionTips":["Keep large data out of eval scripts; pass selectors/ids instead of payloads","Remember CLAUDE_FLOW_MAX_EVAL_SCRIPT_LENGTH is read once at server startup — restart after changing it"],"tags":["browser","eval","input-length","mcp-tools"],"backgroundTag":"input-too-long","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}