sdk icon indicating copy to clipboard operation
sdk copied to clipboard

[UI]: Exception: "Context must be an activity"

Open stefanel96 opened this issue 11 months ago • 14 comments

Describe the bug

This is an exception happening while trying to sign a transaction in TonKeeper on testnet (image attached).

Screenshot 2025-01-02 133230

The mini app is getting this exception thrown, but the transaction is being sent to blockchain and the TON is being billed from the wallet. I was thinking of just catching this case but that's not the solution.

Expected behavior

TON Connect should return an object containing the BoC with transaction information.

Current behavior

An error "Context must be an activity" is being thrown and frontend is unaware what is the transaction BoC, therefore not able to look for it or to send it to backend to check it, while transaction is being sent from wallet.

Steps to Reproduce

I am not able to reproduce the steps as it's happening on random times. When it happens, only the phone restart (and reconnecting of the wallet the PC) helps to stop this issue from repeating each time when trying to sign a transaction. Friend told me that removing of the local storage helped him (which is actually reconnecting of the wallet), but that didn't help me, only restart did.

Environment

It's the latest tonconnect-ui version (2.0.9).

This is happening on all platforms: Android and iOS phones, and PC's (windows 10 and 11). I am unaware if same thing happens on other wallets or on mainnet, as I am currently testing my mini app.

Additional context

No response

stefanel96 avatar Jan 02 '25 12:01 stefanel96

I have the same error. This issue occurs probabilistically, making it quite perplexing.

lascion avatar Jan 03 '25 09:01 lascion

I have the same error. This issue occurs probabilistically, making it quite perplexing.

Are you also using TonKeeper on the testnet?

stefanel96 avatar Jan 04 '25 14:01 stefanel96

May I know if anyone is looking at this issue? @thekiba

stefanel96 avatar Jan 04 '25 14:01 stefanel96

I have the same error. This issue occurs probabilistically, making it quite perplexing.

Are you also using TonKeeper on the testnet?

Yes, tonkeeper testnet

lascion avatar Jan 06 '25 02:01 lascion

Same issue here with tonkeeper.

bc1phugo avatar Jan 12 '25 12:01 bc1phugo

same issue, try sending transaction using tonconnect (tonutils realisation) as soon as I enter the application - immediately this error, although it allows me to confirm the transaction

jobman avatar Jan 13 '25 21:01 jobman

@lascion @jobman @bc1phugo, May I ask you which frameworks/libraries/languages are you using for building the TMA? Did you encounter this error on the iOS or Android wallets?

@jobman It does allow to confirm the transaction but the user can also decline the transaction and we would have no way of knowing that, that is the issue.

My guess is: TonConnect in our app sends a request with Id = 2 and stores that request to match it with the response. When we switch to the wallet, something goes wrong, and the session gets interrupted. TonConnect receives a response with Id = 2, but there’s no request to match it with (likely because requests are cleared when the session breaks). The next time a request is sent with Id = 3, a response for Id = 2 is received instead.

Does anyone knows maybe what can be our next steps in solving this?

stefanel96 avatar Jan 16 '25 13:01 stefanel96

Hello, I am also encountering the same problem on Android and iOS. When trying to connect my wallet to Tonkeeper, the transaction fails and returns this error. This issue is relatively recent, as the transactions were going through correctly last week.

wizidot avatar Jan 16 '25 13:01 wizidot

Here is the example of the transaction that I am declining, then of the one I am accepting. Seems like TonKeeper is multiple times returning "Context must be an Acitivity" error but in the end (before the next request) it returns the result of the action (message of cancellation or transaction hash).

Maybe if we can 'catch' all the 'Context' error before the final one, we can get to the final one? But I am not sure how secure is this approach, as if what happens if the final one never come for some reason and we're left on the 'Context' error?

The one where user declines the transaction: Image

The one where user accepts the transaction: Image

stefanel96 avatar Jan 16 '25 13:01 stefanel96

Reporting the same issue on mainnet. @tonconnect/ui 2.0.9, Tonkeeper 5.0.20 (931) for Android

fastesc avatar Jan 16 '25 17:01 fastesc

@wizidot @jobman @fastesc @lascion @bc1phugo, Guys can you answer me on those questions (you can answer only on the questions you have not already in the previous comments)? I am trying to exclude some 'environment variables' in order to reproduce and narrow down the area of the problem, so that I can solve it.

Questions:

  1. What are you using to build your TMA (which framework, library, language)? If you are not using TMA, what are you using TonConnect for?
  2. Do you know how to reproduce this error?
  3. Did you notice any other pattern before this error comes up?
  4. How do you 'stop' this error, because from my experience, when it starts, I must restart both the Telegram app and the TonKeeper app?

Please, add any additional observations if you have, and I'll share new ones from my side too so we can tackle this issue! :) Cheers

stefanel96 avatar Jan 19 '25 11:01 stefanel96

I encountered the same problem. Has anyone fixed it?

alim-bilimov avatar Jan 21 '25 15:01 alim-bilimov

I encountered the same problem. Has anyone fixed it?

Not that I know of, can you answer me those questions:

  1. What are you using to build your TMA (which framework, library, language)? If you are not using TMA, what are you using TonConnect for?
  2. Do you know how to reproduce this error?
  3. How do you 'stop' this error, because from my experience, when it starts, I must restart the TonKeeper app? But sometimes, that's not enough and I have to restart my TMA in order to work it out

stefanel96 avatar Jan 22 '25 16:01 stefanel96

I had a similar issue with TMA on React, @tonconnect/ui 2.0.11, Tonkeeper 5.0.20 for Android. Reinstalling Tonkeeper on the phone solved the problem. I'm not sure if this solution will work for everyone, but it might be helpful for someone.

AlexandrShulgin avatar Jan 23 '25 18:01 AlexandrShulgin

Fixed in Tonkeeper

jenshenJ avatar Jun 10 '25 14:06 jenshenJ