Skip to content

Getting an error while getting transaction info using getParsedTransactions methodΒ #3721

@VladLypovyi

Description

@VladLypovyi

NOTE: This bug tracker is for the v1.98.0 version of @solana/web3.js.

Overview

Got an error while getting transaction info using getParsedTransactions method

Steps to reproduce

Try to get transaction using getParsedTransactions method

import { Connection } from '@solana/web3.js'; 
const connection = new Connection('rpc_url', { commitment: 'finalized' });
const transaction = await connection.getParsedTransactions(['some_tx_hash'], { maxSupportedTransactionVersion: 0 });

Description of bug

Some nodes return the 'error' property for the successful response ("error":null)

{"jsonrpc":"2.0","result":{"blockTime":1735951045,"meta":{"computeUnitsConsumed":3300,"err":null,"fee":5825,"innerInstructions":[],"header":{"numReadonlySignedAccounts":0,"numReadonlyUnsignedAccounts":2,"numRequiredSignatures":1},"instructions":[],"recentBlockhash":"buuHGVjZVpkSWXkKtveHrTJHQtthUwiWquU3giFm5Fp"},"signatures":["Tj2KrbbudZX2nM5JkdW4ManovBcDw6h7zPnnW4zMtKFnYzSgmd8AmZjeifmdXEJC1QGyHSkiVz8rg1fcLj3m2Qk"]}},"error":null,"id":1}

But the method getParsedTransactions has a check for existing 'error', and throws error that 'failed to get transactions' even for successful responses

/**
   * Fetch parsed transaction details for a batch of confirmed transactions
   */
  async getParsedTransactions(signatures, commitmentOrConfig) {
    const {
      commitment,
      config
    } = extractCommitmentFromConfig(commitmentOrConfig);
    const batch = signatures.map(signature => {
      const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed', config);
      return {
        methodName: 'getTransaction',
        args
      };
    });
    const unsafeRes = await this._rpcBatchRequest(batch);
    const res = unsafeRes.map(unsafeRes => {
      const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
      if ('error' in res) {
        throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
      }
      return res.result;
    });
    return res;
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions