{"record":{"id":"6b4e99ea3ebf09ee","repo":"remotion-dev/remotion","slug":"not-enough-data-to-get-track-number-should-not-ha","errorCode":null,"errorMessage":"Not enough data to get track number, should not happen","messagePattern":"Not enough data to get track number, should not happen","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/webm/get-sample-from-block.ts","lineNumber":135,"sourceCode":"\tavcState,\n}: {\n\tebml: BlockSegment | SimpleBlockSegment;\n\twebmState: WebmState;\n\toffset: number;\n\tstructureState: StructureState;\n\tcallbacks: CallbacksState;\n\tlogLevel: MediaParserLogLevel;\n\tonVideoTrack: MediaParserOnVideoTrack | null;\n\tavcState: AvcState;\n}): Promise<SampleResult> => {\n\tconst iterator = getArrayBufferIterator({\n\t\tinitialData: ebml.value,\n\t\tmaxBytes: ebml.value.length,\n\t\tlogLevel: 'error',\n\t});\n\tconst trackNumber = iterator.getVint();\n\tif (trackNumber === null) {\n\t\tthrow new Error('Not enough data to get track number, should not happen');\n\t}\n\n\tconst timecodeRelativeToCluster = iterator.getInt16();\n\n\tconst {keyframe} = parseBlockFlags(\n\t\titerator,\n\t\tebml.type === 'SimpleBlock'\n\t\t\t? matroskaElements.SimpleBlock\n\t\t\t: matroskaElements.Block,\n\t);\n\n\tconst {codec, trackTimescale} = webmState.getTrackInfoByNumber(trackNumber);\n\n\tconst clusterOffset = webmState.getTimestampOffsetForByteOffset(offset);\n\n\tconst timescale = webmState.getTimescale();\n\n\tif (clusterOffset === undefined) {","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/webm/get-sample-from-block.ts#L117-L153","documentation":"Thrown at get-sample-from-block.ts:135 when `iterator.getVint()` returns null while reading the track-number Vint at the start of a Matroska Block/SimpleBlock payload. The message 'should not happen' reflects that a Block should always carry at least one track-number byte; reaching EOF means the Block element's declared size exceeded its actual data.","triggerScenarios":"Parsing a `Block` or `SimpleBlock` element whose `ebml.value` buffer is empty or shorter than a Vint (≥1 byte). Caused by truncated cluster data, a wrong element size in the EBML, or a partially flushed stream read.","commonSituations":"Streaming a WebM over an unreliable network where the connection drops mid-cluster; files truncated by an interrupted recording (screen recorders, live streams); incorrect Content-Length on a fetch response feeding the parser reader.","solutions":["Verify the source is a complete file: check file size / re-download / compare to a known-good copy.","If streaming, ensure the reader delivers the full Block payload before the parser consumes it; prefer a buffered File/Blob source.","Re-mux with ffmpeg to repair truncation: `ffmpeg -i broken.webm -c copy repaired.webm` (ffmpeg will skip incomplete blocks).","Catch the error and treat the asset as unreadable rather than crashing."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check: ensure the source is a complete, non-truncated file.\nasync function isComplete(src) {\n  if (src instanceof File || src instanceof Blob) {\n    return src.size > 0;\n  }\n  if (typeof src === 'string') {\n    const res = await fetch(src, { method: 'HEAD' });\n    return res.ok && Number(res.headers.get('content-length') ?? 0) > 0;\n  }\n  return true;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await parseMedia({ src, fields: { samples: true } });\n} catch (err) {\n  if (err instanceof Error && /should not happen/.test(err.message)) {\n    // Block payload was truncated — file is incomplete or corrupt.\n    console.warn('Truncated WebM block in', src, '— re-download or re-mux.');\n    return null;\n  }\n  throw err;\n}","preventionTips":["Prefer complete File/Blob sources over live network streams for WebM parsing.","Verify downloads completed fully (compare Content-Length to actual bytes).","Re-mux truncated files with ffmpeg before parsing: ffmpeg skips incomplete blocks.","For streaming sources, ensure the reader buffers entire Block payloads before yielding them."],"tags":["media-parser","webm","matroska","truncated-input","vint"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}