Token payment issue with web3.js and metamask

Hi,

When I use Web3.js with MetaMask to pay tokens, I first approve the token spending. However, if I confirm the send transaction request in the MetaMask popup without closing the approval success popup, I receive the following MetaMask error:

Error:
“Could not coalesce error (error={ “code”: -32603, “message”: “Request of type ‘smartTransaction:showSmartTransactionStatusPage’ already pending for origin chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn. Please wait.” }…)”

Despite this error, the transaction is actually confirmed successfully.

I want to get the transaction hash when this error occurs or revert the transaction with an alert.

How can I handle this issue?

Hi which version are you testing and what device and OS?

(post deleted by author)

Thanks for your reply.

I am using Windows system and Chrome.
My code was working well 3 days ago, but it shows error today.
MetaMask Version: 12.12.0


I uploaded screenshots.


By pending error, transaction is reverted. So I can’t get transaction hash after transaction is confirmed.

did you use any code source or it’s your code. What is the goal maybe I could find you an already existing solution

I am currently building a crypto-related service, and I’ve encountered an issue that I believe some users may also face.

In my code, I first call the approve function of a smart contract. Once the approval transaction is successful, I then call the pay function.

However, if I confirm the pay transaction in MetaMask without closing the success modal of the approve transaction like above screenshots, an error occurs.

In this situation, MetaMask displays a failed transaction alert due to the pending transaction modal, but I believe the transaction should stop at that point instead of continuing.

Right now, my code execution halts when the first failed transaction occurs, which prevents me from retrieving the transaction results and hash after confirming the transaction.

I found this Stack Overflow post, but no solution was found.
…/questions/79435935/receiving-an-error-after-a-toast-message-although-the-transaction-is-done-succe

I would like to know how to retrieve the transaction result even if this error occurs or prevent the transaction from being confirmed in such cases.