FuelLabs/fuels-ts · error · Error

Too many instructions, exceeding u16::MAX.

Error message

Too many instructions, exceeding u16::MAX.

What it means

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.

Source

Thrown at packages/account/src/utils/predicate-script-loader-instructions.ts:167

  const offset = getBytecodeConfigurableOffset(originalBinary);

  // if the binary length is smaller than the offset
  if (originalBinary.length < offset) {
    throw new Error(
      `Data section offset is out of bounds, offset: ${offset}, binary length: ${originalBinary.length}`
    );
  }

  // Extract the configurable section from the binary (slice from the configurable offset onwards)
  const configurableSection = originalBinary.slice(offset);

  // Check if the configurable section is non-empty
  if (configurableSection.length > 0) {
    // Get the number of instructions (assuming it won't exceed u16::MAX)
    const numOfInstructions = getInstructions(0).length;
    if (numOfInstructions > 65535) {
      throw new Error('Too many instructions, exceeding u16::MAX.');
    }

    // Convert instructions to bytes
    const instructionBytes = new Uint8Array(
      getInstructions(numOfInstructions).flatMap((instruction) =>
        Array.from(instruction.to_bytes())
      )
    );

    // Convert blobId to bytes
    const blobBytes = new Uint8Array(blobId);

    // Convert data section length to big-endian 8-byte array
    const dataSectionLenBytes = new Uint8Array(8);
    const dataView = new DataView(dataSectionLenBytes.buffer);
    dataView.setBigUint64(0, BigInt(configurableSection.length), false); // false for big-endian

    // Combine the instruction bytes, blob bytes, data section length, and the data section

View on GitHub (pinned to b3f37c91ac)

Solutions

  1. This indicates an SDK/vm-asm bug, not a usage error — report it with the bytecode and package versions.
  2. Pin @fuels/vm-asm and fuels-ts to known-compatible versions.
  3. If developing the SDK, audit getInstructions() for unintended instruction duplication.
Defensive patterns

Strategy: try-catch

Try / catch

try { const loader = getPredicateScriptLoaderInstructions(bytecode, blobId); }
catch (e) { /* internal SDK invariant — report upstream */ throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of FuelLabs/fuels-ts@b3f37c91ac (2026-08-12). Data as JSON: /api/errors/704a5e4c66e523cd. Report an issue: GitHub.