{"record":{"id":"842059557efb5bb7","repo":"denoland/deno","slug":"err-http2-altsvc-length","errorCode":"ERR_HTTP2_ALTSVC_LENGTH","errorMessage":"HTTP/2 ALTSVC frames are limited to 16382 bytes","messagePattern":"HTTP/2 ALTSVC frames are limited to 16382 bytes","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/http2.ts","lineNumber":4628,"sourceCode":"          \"number\",\n          \"URL\",\n          \"object\",\n        ], originOrStream);\n      } else if (origin === \"null\" || origin.length === 0) {\n        throw new ERR_HTTP2_ALTSVC_INVALID_ORIGIN();\n      }\n    }\n\n    validateString(alt, \"alt\");\n    if (!kQuotedString.test(alt)) {\n      throw new ERR_INVALID_CHAR(\"alt\");\n    }\n\n    // Max length permitted for ALTSVC\n    if (\n      (alt.length + (origin !== undefined ? origin.length : 0)) > kMaxALTSVC\n    ) {\n      throw new ERR_HTTP2_ALTSVC_LENGTH();\n    }\n\n    this[kHandle].altsvc(stream, origin || \"\", alt);\n  }\n\n  // Submits an origin frame to be sent.\n  origin(...origins) {\n    if (this.destroyed) {\n      throw new ERR_HTTP2_INVALID_SESSION();\n    }\n\n    if (origins.length === 0) {\n      return;\n    }\n\n    let arr = \"\";\n    let len = 0;\n    const count = origins.length;","sourceCodeStart":4610,"sourceCodeEnd":4646,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/http2.ts#L4610-L4646","documentation":"An ALTSVC frame's payload is capped at kMaxALTSVC = 2**14 - 2 = 16382 bytes. altsvc() throws ERR_HTTP2_ALTSVC_LENGTH when alt.length plus origin.length (when an origin string is present) exceeds that budget, because the frame cannot carry more without violating the protocol's 16-bit length field.","triggerScenarios":"A single altsvc call whose alt value and origin together exceed 16382 characters — e.g. advertising many protocols/hosts in one alt string built by concatenation.","commonSituations":"Generating the alt value from a large service catalog or long list of alternative endpoints; unbounded user-supplied alt-svc config; a loop that appends entries to one alt string instead of issuing one altsvc() per entry.","solutions":["Split into multiple altsvc() calls — each call is its own frame, so advertise one (or few) alternates per call","Trim the origin and alt to what the peer can actually use (typically 'h2=\":port\"', ~12 bytes)","Cap config-driven alt values at a sane length (e.g. 256 bytes) before submission"],"exampleFix":"// before\nconst alt = endpoints.map((e) => `h2=\"${e.host}:${e.port}\"`).join(',');\nsession.altsvc(alt, origin); // can exceed 16382\n\n// after\nfor (const e of endpoints) session.altsvc(`h2=\"${e.host}:${e.port}\"`, origin);","handlingStrategy":"validation","validationCode":"const originLen = typeof origin === 'string' ? origin.length : 0;\nif (alt.length + originLen > 16382) {\n  throw new RangeError('alt + origin exceeds the ALTSVC frame limit of 16382 bytes');\n}\nsession.altsvc(alt, origin);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One alternate per altsvc() call — each call is a separate frame","Cap config-supplied alt values (256 bytes is generous; real values are ~10-30)","The budget counts origin.length too when a string origin is present"],"tags":["http2","node-compat","altsvc","size-limit"],"backgroundTag":"payload-too-large","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}