anza-xyz / wallet-adapter

Modular TypeScript wallet adapters and components for Solana applications.
https://anza-xyz.github.io/wallet-adapter/
Apache License 2.0
1.44k stars 906 forks source link

WalletSignTransactionError: Reached end of buffer unexpectedly #983

Closed francestu96 closed 3 weeks ago

francestu96 commented 3 weeks ago

I get the subject error in production whereas locally it works as expected. I already checked the environments both on prod and locally are the same.

The code is simply the following:

const wallet = useAnchorWallet();
const provider = new AnchorProvider(connection, wallet!, {});
const program = new Program<Test>(idl as Test, provider);

const tx = await program.methods
          .myMethod()
          .accounts({ sender: wallet!.publicKey})
          .transaction();

const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
tx.recentBlockhash = blockhash;
tx.feePayer = wallet!.publicKey;

const signedTx = await wallet!.signTransaction(tx);
const txId = await connection.sendRawTransaction(signedTx.serialize());

await connection.confirmTransaction({
  blockhash: blockhash, 
  lastValidBlockHeight: lastValidBlockHeight,
  signature: txId
});

Why locally it works and in prod I got that weird error message during the transaction sign process?

UPDATE: this happends on Phantom wallet. By using Solflare instead, I got WalletSignTransactionError: Blob.encode[recentBlockhash] requires (length 32) Uint8Array as src in production and not locally again

francestu96 commented 3 weeks ago

I found the problem is caused by a compression/minify process. In my case I fixed by removing swcMinify: true from next.config.js!