{"record":{"id":"1a5a159d9458a7dc","repo":"musistudio/claude-code-router","slug":"script-result-exceeds-maxresultbytes-bytes","errorCode":null,"errorMessage":"Script result exceeds ${maxResultBytes} bytes.","messagePattern":"Script result exceeds (.+?) bytes\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/routing/route-script-worker.ts","lineNumber":313,"sourceCode":"\nfunction assertHttpUrl(rawUrl: string): void {\n  let url: URL;\n  try {\n    url = new URL(rawUrl);\n  } catch {\n    throw new Error(`Invalid URL \"${rawUrl}\".`);\n  }\n  if ((url.protocol !== \"http:\" && url.protocol !== \"https:\") || url.username || url.password || !url.hostname) {\n    throw new Error(\"Only HTTP(S) URLs without embedded credentials are supported.\");\n  }\n}\n\nfunction serializeResult(value: unknown): unknown {\n  if (value === undefined) return undefined;\n  const encoded = JSON.stringify(value);\n  if (encoded === undefined) throw new Error(\"Script result must be JSON serializable.\");\n  if (Buffer.byteLength(encoded, \"utf8\") > maxResultBytes) {\n    throw new Error(`Script result exceeds ${maxResultBytes} bytes.`);\n  }\n  return JSON.parse(encoded);\n}\n\nasync function withDeadline<T>(promise: Promise<T>, deadline: number): Promise<T> {\n  const remainingMs = Math.max(1, deadline - Date.now());\n  let timer: NodeJS.Timeout | undefined;\n  try {\n    return await Promise.race([\n      promise,\n      new Promise<T>((_resolve, reject) => {\n        timer = setTimeout(() => reject(timeoutError()), remainingMs);\n      })\n    ]);\n  } finally {\n    if (timer) clearTimeout(timer);\n  }\n}","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/musistudio/claude-code-router/blob/99f24806c6a2c660b16e53e95211c517448a6c90/packages/core/src/routing/route-script-worker.ts#L295-L331","documentation":"Error \"Script result exceeds ${maxResultBytes} bytes.\" thrown in musistudio/claude-code-router.","triggerScenarios":"Thrown at packages/core/src/routing/route-script-worker.ts:313 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"99f24806c6a2c660b16e53e95211c517448a6c90","analyzedAt":"2026-08-27T04:11:01.184Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}