{"record":{"id":"704a5e4c66e523cd","repo":"FuelLabs/fuels-ts","slug":"too-many-instructions-exceeding-u16-max","errorCode":null,"errorMessage":"Too many instructions, exceeding u16::MAX.","messagePattern":"Too many instructions, exceeding u16::MAX\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/account/src/utils/predicate-script-loader-instructions.ts","lineNumber":167,"sourceCode":"\n  const offset = getBytecodeConfigurableOffset(originalBinary);\n\n  // if the binary length is smaller than the offset\n  if (originalBinary.length < offset) {\n    throw new Error(\n      `Data section offset is out of bounds, offset: ${offset}, binary length: ${originalBinary.length}`\n    );\n  }\n\n  // Extract the configurable section from the binary (slice from the configurable offset onwards)\n  const configurableSection = originalBinary.slice(offset);\n\n  // Check if the configurable section is non-empty\n  if (configurableSection.length > 0) {\n    // Get the number of instructions (assuming it won't exceed u16::MAX)\n    const numOfInstructions = getInstructions(0).length;\n    if (numOfInstructions > 65535) {\n      throw new Error('Too many instructions, exceeding u16::MAX.');\n    }\n\n    // Convert instructions to bytes\n    const instructionBytes = new Uint8Array(\n      getInstructions(numOfInstructions).flatMap((instruction) =>\n        Array.from(instruction.to_bytes())\n      )\n    );\n\n    // Convert blobId to bytes\n    const blobBytes = new Uint8Array(blobId);\n\n    // Convert data section length to big-endian 8-byte array\n    const dataSectionLenBytes = new Uint8Array(8);\n    const dataView = new DataView(dataSectionLenBytes.buffer);\n    dataView.setBigUint64(0, BigInt(configurableSection.length), false); // false for big-endian\n\n    // Combine the instruction bytes, blob bytes, data section length, and the data section","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/account/src/utils/predicate-script-loader-instructions.ts#L149-L185","documentation":"Thrown by getPredicateScriptLoaderInstructions() when the loader stub generated for bytecode that HAS a configurable section would exceed u16::MAX (65535) instructions. The loader instructions are a fixed, hand-authored sequence, so under normal operation this is unreachable; it guards against a pathological change in the vm-asm instruction encoding.","triggerScenarios":"Effectively unreachable through public APIs in released SDK versions. Would only fire if the @fuels/vm-asm Instruction set expanded dramatically or getInstructions() was modified to emit tens of thousands of ops.","commonSituations":"Local SDK development where vm-asm constants were changed; a fork that appends many custom loader steps; corrupted vm-asm package producing oversized instruction arrays.","solutions":["This indicates an SDK/vm-asm bug, not a usage error — report it with the bytecode and package versions.","Pin @fuels/vm-asm and fuels-ts to known-compatible versions.","If developing the SDK, audit getInstructions() for unintended instruction duplication."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { const loader = getPredicateScriptLoaderInstructions(bytecode, blobId); }\ncatch (e) { /* internal SDK invariant — report upstream */ throw e; }","preventionTips":["Pin @fuels/vm-asm and fuels-ts to known-compatible versions.","Report this as an SDK bug; it is not user-triggerable under normal use."],"tags":["predicate","bytecode","internal","loader","unreachable"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}