Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WalletSignTransactionError: Something went wrong. #581

Closed
stanleycyang opened this issue Oct 4, 2022 · 21 comments
Closed

WalletSignTransactionError: Something went wrong. #581

stanleycyang opened this issue Oct 4, 2022 · 21 comments
Labels
bug Something isn't working question Add this to close an issue with instructions on how to repost as a question on Stack Exchange

Comments

@stanleycyang
Copy link

stanleycyang commented Oct 4, 2022

Describe the bug

When I'm testing in local development (w/ mainnet-beta and custom RPC), our airdrop code works perfectly. but when moving it into prod, it complains WalletSignTransactionError: Something went wrong.. I checked all the ENV variables and made sure it was the same.

To Reproduce

const transaction = new Transaction();

      // create token account
      if (receiverAccount == null) {
        transaction.add(
          createAssociatedTokenAccountInstruction(
            sender,
            receiverATA,
            receiver,
            mint
          )
        );
      }

      // add transfer instruction
      transaction.add(
        createTransferCheckedInstruction(
          senderATA,
          mint,
          receiverATA,
          sender,
          1,
          0
        )
      );

      const recentBlockhash = await connection.getLatestBlockhash();
      transaction.recentBlockhash = recentBlockhash?.blockhash;
      transaction.feePayer = sender;

      await signTransaction(transaction);

Expected behavior
I expected to work in both production and development

Screenshots
Screen Shot 2022-10-04 at 3 45 21 PM
Screen Shot 2022-10-04 at 3 45 18 PM

Screen Shot 2022-10-04 at 5 13 04 PM

Desktop (please complete the following information):

  • OS: MacOS monterey
  • Browser chrome
  • Version latest

Additional context
NA

@jordaaash jordaaash added the question Add this to close an issue with instructions on how to repost as a question on Stack Exchange label Oct 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2022

Hi @stanleycyang,

Thanks for your question!

We want to make sure to keep signal strong in the GitHub issue tracker – to make sure that it remains the best place to track issues that affect the development of Solana itself.

Questions like yours deserve a purpose-built Q&A forum. Unless there exists evidence that this is a bug with Solana itself, please post your question to the Solana Stack Exchange using this link: https://solana.stackexchange.com/questions/ask


This automated message is a result of having added the ‘question’ tag.

@github-actions github-actions bot closed this as completed Oct 5, 2022
@jordaaash
Copy link
Collaborator

If the signing request is reaching the wallet, this doesn't seem related to Wallet Adapter. Unfortunately we can't help troubleshoot issues with wallets or deployment environments.

@jordaaash
Copy link
Collaborator

Also just noting, your reproduction code isn't something I can run. Lots of variables not defined, and you said it works in development against mainnet anyway. This points to an issue with your production build or environment.

@stanleycyang
Copy link
Author

Fair enough. I am seeing the try catch fail specifically around the signTransaction in production though, which is odd. is there some potentially this package works differently in nextjs => vercel?

@stanleycyang
Copy link
Author

I do see this as a recurring issue in the solana discord as well:
Screen Shot 2022-10-04 at 7 51 29 PM

@jordaaash
Copy link
Collaborator

That's not a recurring issue. That's two different issues with different JS libraries under different circumstances. Their commonality is most likely user error.

Please follow up if you find a bug that can be reproduced with a complete repo. For example, if you provide a repo with a Next.js that works locally on mainnet but fails when deployed, I can take a look.

@stanleycyang
Copy link
Author

Hey @jordansexton, here is a test repo: https://conversion-test.vercel.app/

Here is the code: https://github.com/fellowshipdao/conversion-test. I just ramped it up locally with some of the example repo code and it seems like it works locally but not in prod. any idea?

@jordaaash
Copy link
Collaborator

Thanks, looking into this!

@stanleycyang
Copy link
Author

Hearing some talk about other people having issues on deployment to Vercel now as well with the core solana labs libs. I'm having trouble debugging since the error code is fairly generic. any ideas on what I did wrong here?

@jordaaash jordaaash reopened this Oct 6, 2022
@jordaaash
Copy link
Collaborator

Can you try to deploy the Next.js starter project and tell me if there are issues there? I've run this locally without a problem, but haven't deployed it recently. You may have to update the config to include the wallets you're testing.

@stanleycyang
Copy link
Author

I believe I deployed almost that code in the other instance. I can try and clone and deploy this one

@kimpers
Copy link

kimpers commented Oct 14, 2022

For what it's worth this does not seem to have anything to do with Vercel but rather the Next.js build process. Running yarn next build && yarn next start will cause it to break when served locally as well

@jordaaash
Copy link
Collaborator

Thanks! I'll test that.

@saurabhsri108
Copy link

saurabhsri108 commented Oct 15, 2022

This fails in local after build as well. Have similar issue but not entirely same, here in my devnet (so it doesn't have any relation with devnet, testnet, mainnet) -> https://nextsol.ibcoder.com. GitHub code: https://github.com/vasudeveloper001/solana-next-app

It definitely fails during build in nextjs.
image

Using source-map debugging, it is pointing to wallet-adapter's code around here:

adapter.js code piece pointed by source-maps.

async sendTransaction(transaction, connection, options = {}) {
        try {
            const wallet = this._wallet;
            if (!wallet)
                throw new WalletNotConnectedError();
            try {
                const { signers, ...sendOptions } = options;
                transaction = await this.prepareTransaction(transaction, connection, sendOptions);
                signers?.length && transaction.partialSign(...signers);
                sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment;
                const { signature } = await wallet.signAndSendTransaction(transaction, sendOptions);
                return signature;
            }
            catch (error) {
                if (error instanceof WalletError)
                    throw error;
                throw new WalletSendTransactionError(error?.message, error);
            }
        }
        catch (error) {
            this.emit('error', error);
            throw error;
        }
    }

Wallet-Provider calls adapter.js above

const sendTransaction = useCallback(
  async (transaction, connection, options) => {
    if (!adapter) throw handleError(new WalletNotSelectedError());
    if (!connected) throw handleError(new WalletNotConnectedError());
    return await adapter.sendTransaction(transaction, connection, options);
  },
  [adapter, handleError, connected]
);

Weird thing, this used to work like few months back!

EDIT: Also tried changing the checkout page to getServerSideProps type. Doesn't work. Removing authentication check on the page, doesn't work either. And it fails with SolFare as well, so have nothing to do with Wallets either.

@kimpers
Copy link

kimpers commented Oct 17, 2022

It seems like this issue is related to some change with the build/tree shaking process for Next.js 12. Downgrading to Next.js ^11.1.4 resolved the issue for me

@jordaaash
Copy link
Collaborator

Hmm, the example and nextjs-starter projects both use Next 12 and build and run locally for me. I'll try with them moved out of the workspace in case it's a dependency resolution issue.

@YoungMahesh
Copy link

Can you try to deploy the Next.js starter project and tell me if there are issues there? I've run this locally without a problem, but haven't deployed it recently. You may have to update the config to include the wallets you're testing.

@jordansexton , I had exactly same problem mentioned by @stanleycyang on the top and using Next.js starter resolved my issue. (I also tried Downgrading to Next.js ^11.1.4 as mentioned by @kimpers but it didn't worked for me)

@jordaaash
Copy link
Collaborator

@YoungMahesh great! I might go ahead and do some testing with a vanilla Next app just to understand what the issue is and why the starter works if that doesn't.

@steveluscher
Copy link
Collaborator

I'm going to guess this is related to vercel/next.js#41527 and fixed by swc-project/swc#6201.

Were you folks using the swcMinify: true option?

@jordaaash jordaaash added the bug Something isn't working label Oct 20, 2022
@saurabhsri108
Copy link

@steveluscher You're right. swcMinify is the problem. Setting it to false in next.config.js makes the site works: https://nextsol.ibcoder.com

@steveluscher
Copy link
Collaborator

steveluscher commented Oct 21, 2022

This is fixed in vercel/next.js v12.3.2-canary.32. Update and you're on your way!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Add this to close an issue with instructions on how to repost as a question on Stack Exchange
Projects
None yet
Development

No branches or pull requests

6 participants