Open Jandzi opened 9 months ago
For me it helped to wait 5 seconds and use another way to validate the transaction:
await new Promise(r => setTimeout(r, 5000));
const result = await connection.getSignatureStatus(txid, {
searchTransactionHistory: true,
});
console.log(result);
An even better addition:
// Execute the transaction
var tryAgain=true;
var objSignatureStatusResult;
var maxTriesCounter=0;
var maxTries=5;
while (tryAgain) {
maxTriesCounter++;
const rawTransaction = transaction.serialize()
const txid = await connection.sendRawTransaction(rawTransaction, {
skipPreflight: true,
maxRetries: 2
});
console.log(`https://solscan.io/tx/${txid}`);
await new Promise(r => setTimeout(r, 1500));
const result = await connection.getSignatureStatus(txid, {
searchTransactionHistory: true,
});
objSignatureStatusResult = JSON.parse(JSON.stringify(result));
if ( objSignatureStatusResult.value !== null) tryAgain=false;
if (maxTriesCounter>maxTries) tryAgain=false;
}
I'm facing the exact same issue. If I try to swap a less busy token - it works almost every time, however, with busier tokens it rarely succeeds. Did you ever find a solution to the problem?
An even better addition:
// Execute the transaction var tryAgain=true; var objSignatureStatusResult; var maxTriesCounter=0; var maxTries=5; while (tryAgain) { maxTriesCounter++; const rawTransaction = transaction.serialize() const txid = await connection.sendRawTransaction(rawTransaction, { skipPreflight: true, maxRetries: 2 }); console.log(`https://solscan.io/tx/${txid}`); await new Promise(r => setTimeout(r, 1500)); const result = await connection.getSignatureStatus(txid, { searchTransactionHistory: true, }); objSignatureStatusResult = JSON.parse(JSON.stringify(result)); if ( objSignatureStatusResult.value !== null) tryAgain=false; if (maxTriesCounter>maxTries) tryAgain=false; }
You are a life saver, thank you very much! Everything works now!
I'm facing the exact same issue. If I try to swap a less busy token - it works almost every time, however, with busier tokens it rarely succeeds. Did you ever find a solution to the problem?
Yes, as zerotop pointed out, you have to add the while loop, that basically retries to executing the transaction.
Hi guys, I just started to use the Jupiter APIs, but I have one problem with them. It is terribly slow. The code does work, it will swap, but 9 out of 10 times it will time out and I don't know why. I tried to find out where the code gets stuck and it is on the following code:
await connection.confirmTransaction(txid);
Why could that be? I have also used different RPC endpoints, for example the Helius one, and it was still super slow. I have also made a "race" between trying to swap in in the Jupiter GUI using my custom Helios RPC endpoint and my code with the same Helios RPC endpoint and the GUI was significantly faster. What am I missing please? This is the code:Thank you for you time!