{"record":{"id":"a52405494f0ffc20","repo":"agalwood/Motrix","slug":"manifest-too-large-text-length-max","errorCode":null,"errorMessage":"manifest too large: ${text.length} > ${max}","messagePattern":"manifest too large: (.+?) > (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/core/media/manifest-fetcher.ts","lineNumber":23,"sourceCode":"  opts: {\n    headers?: Record<string, string>\n    fetchImpl?: typeof fetch\n    maxBytes?: number\n  } = {}\n): Promise<string> {\n  const doFetch = opts.fetchImpl ?? fetch\n  const res = await doFetch(url, {\n    method: 'GET',\n    headers: opts.headers ?? {},\n    redirect: 'follow',\n  })\n  if (!res.ok) {\n    throw new Error(`manifest fetch failed: HTTP ${res.status}`)\n  }\n  const text = await res.text()\n  const max = opts.maxBytes ?? DEFAULT_MAX\n  if (text.length > max) {\n    throw new Error(`manifest too large: ${text.length} > ${max}`)\n  }\n  return text\n}\n","sourceCodeStart":5,"sourceCodeEnd":27,"githubUrl":"https://github.com/agalwood/Motrix/blob/1a708ee57746c434e2c67a44bbf0906a976afea4/src/core/media/manifest-fetcher.ts#L5-L27","documentation":"Plain Error thrown by fetchManifest when the response body length exceeds opts.maxBytes (default 5 MiB). The guard prevents a malicious or misconfigured origin from exhausting memory by serving an arbitrarily large 'manifest' — a denial-of-service protection at the trust boundary.","triggerScenarios":"Calling fetchManifest against a URL whose response body is larger than the cap — e.g. an HLS master with thousands of variants, a DASH MPD that inlines SegmentTimeline with millions of <S> entries, or accidentally pointing the manifest fetcher at a media segment / large JSON endpoint.","commonSituations":"URL dispatch bug sending the fetcher at a media segment or full MP4 instead of the manifest; oversized live-window manifests; CDN returning an error page (large HTML) with a 200 status; legitimate large manifests that exceed the 5 MiB default.","solutions":["Verify the URL points at a manifest (HLS .m3u8 / DASH .mpd) and not at a media file.","If the manifest is legitimately large, raise opts.maxBytes to an explicit value you have reasoned about.","Inspect Content-Type and Content-Length of the response before/after to confirm it is actually a manifest.","If a CDN is returning a 200 HTML error page, fix the upstream routing."],"exampleFix":"// before\nconst text = await fetchManifest(url, {})\n// after — confirm it's a manifest and raise cap if legitimate\nconst text = await fetchManifest(url, {\n  maxBytes: 10 * 1024 * 1024,\n  headers: { Accept: 'application/vnd.apple.mpegurl, application/dash+xml' },\n})\nif (!/^#|<\\?xml|<MPD/.test(text.trimStart())) {\n  throw new Error('Response does not look like a manifest')\n}","handlingStrategy":"validation","validationCode":"function looksLikeManifest(text: string): boolean {\n  return /^\\s*(#|<\\?xml|<MPD)/.test(text)\n}\nconst text = await fetchManifest(url, { maxBytes: 10 * 1024 * 1024 })\nif (!looksLikeManifest(text)) {\n  throw new Error('Response is not a manifest (HLS/DASH). Check the URL.')\n}","typeGuard":"function looksLikeManifest(text: string): boolean {\n  return /^\\s*(#EXTM3U|<\\?xml|<MPD\\b)/.test(text)\n}","tryCatchPattern":"try {\n  const text = await fetchManifest(url, { maxBytes })\n} catch (e) {\n  if (/manifest too large/.test(String(e))) {\n    // either raise maxBytes after reasoning, or reject the URL as not-a-manifest\n  } else throw e\n}","preventionTips":["Confirm URL points at a manifest and not a media segment before fetching.","Set opts.maxBytes to a value you have reasoned about for your asset catalogue.","Inspect Content-Type/Content-Length of suspicious responses to detect CDN error pages."],"tags":["network","http","security","dos-protection","media"],"backgroundTag":null,"analyzedSha":"1a708ee57746c434e2c67a44bbf0906a976afea4","analyzedAt":"2026-08-12T16:18:09.346Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}