Chia-Network / chia-blockchain-gui

Chia blockchain GUI in electron/react
https://chia.net
Apache License 2.0
331 stars 247 forks source link

[Bug] WalletConnect heavy request fail #1790

Open Ganbin opened 1 year ago

Ganbin commented 1 year ago

What happened?

Description

When making a WC request that may return a lot of data, the request get stack somewhere and we never get any result.

How to reproduce

There are 2 ways to reproduce the issue:

  1. We need to have at least 1 NFT that has its data stored on chain. AnnoyNation or SpaceMarmot. Then make a WC chia_getNFTs request with the wallet that contains the NFT. Having a wallet with hundreds of NFTs may also have the same issue if we don't paginate.
  2. We need a DID wallet with a coin that has a long history of parent_coin_info attribute when doing a chia rpc wallet get_wallets '{"include_data": true}'. Mine has more than 200 parent coins. Then do a WC chia_getWallets with include_data": true.

For both cases, I see the confirmation dialog, the issue occurs after accepting the request in the Chia wallet.

Actual result

Nothing happens both on Chia wallet and on the browser. The only error I get is when opening the developer tools on the Chia wallet, I see some ws.ts:94 WebSocket is already in CLOSING or CLOSED state. errors. On the browser, it just wait until a long timeout and throw an empty error. Nothing on the debug.log

Expected result

The data to be sent or an error message.

References

Discussion #14526 chia_getWallets https://github.com/Chia-Network/chia-blockchain/discussions/14526#discussioncomment-5884656 chia_getNFTs https://github.com/Chia-Network/chia-blockchain/discussions/14526#discussioncomment-5884500

Version

1.8.1

What platform are you using?

macOS

What ui mode are you using?

GUI

Relevant log output

ws.ts:94 WebSocket is already in CLOSING or CLOSED state.
ws.ts:94 WebSocket is already in CLOSING or CLOSED state.
ws.ts:94 WebSocket is already in CLOSING or CLOSED state.
...
Ganbin commented 1 year ago

After activating chia debug I can see that Chia Wallet seems to successfully send the data. I got this log :

chia-gui:walletConnect result +57ms {status: 'fulfilled', endpointName: 'getWallets', requestId: ...

All the data are there. The object stringify is 107KB.

I didn't make investigations but I suppose the issue is on the webSocket connection when the data exceed a certain amount.

Ganbin commented 1 year ago
Here is the stack of the origin of the error: ```log WebbSocket is already in CLOSING or CLOSED state. (anonymous) @ ws.ts:94 l @ ws.ts:2 (anonymous) @ ws.ts:2 (anonymous) @ ws.ts:2 ye @ ws.ts:2 a @ ws.ts:2 (anonymous) @ ws.ts:2 (anonymous) @ ws.ts:2 (anonymous) @ ws.ts:98 (anonymous) @ provider.ts:82 l @ provider.ts:2 (anonymous) @ provider.ts:2 (anonymous) @ provider.ts:2 se @ provider.ts:2 a @ provider.ts:2 (anonymous) @ provider.ts:2 (anonymous) @ provider.ts:2 (anonymous) @ provider.ts:86 (anonymous) @ provider.ts:66 l @ provider.ts:2 (anonymous) @ provider.ts:2 (anonymous) @ provider.ts:2 se @ provider.ts:2 a @ provider.ts:2 (anonymous) @ provider.ts:2 (anonymous) @ provider.ts:2 (anonymous) @ provider.ts:87 (anonymous) @ provider.ts:57 l @ provider.ts:2 (anonymous) @ provider.ts:2 (anonymous) @ provider.ts:2 se @ provider.ts:2 a @ provider.ts:2 (anonymous) @ provider.ts:2 (anonymous) @ provider.ts:2 (anonymous) @ provider.ts:58 (anonymous) @ ws.ts:31 l @ ws.ts:31 (anonymous) @ ws.ts:31 (anonymous) @ ws.ts:31 Ce @ ws.ts:31 a @ ws.ts:31 Promise.then (async) Ce @ ws.ts:31 a @ ws.ts:31 (anonymous) @ ws.ts:31 (anonymous) @ ws.ts:31 (anonymous) @ ws.ts:31 value @ ws.ts:31 (anonymous) @ ws.ts:31 l @ ws.ts:31 (anonymous) @ ws.ts:31 (anonymous) @ ws.ts:31 Ce @ ws.ts:31 a @ ws.ts:31 (anonymous) @ ws.ts:31 (anonymous) @ ws.ts:31 (anonymous) @ ws.ts:31 (anonymous) @ ws.ts:31 l @ ws.ts:31 (anonymous) @ ws.ts:31 (anonymous) @ ws.ts:31 Ce @ ws.ts:31 a @ ws.ts:31 (anonymous) @ ws.ts:31 (anonymous) @ ws.ts:31 (anonymous) @ ws.ts:31 value @ ws.ts:31 (anonymous) @ ws.ts:31 emit @ node:events:525 value @ heartbeat.ts:56 (anonymous) @ heartbeat.ts:52 ```

The error seems to origin from walletconnect-utils/misc/heartbeat/src/heartbeat.ts#L52

An additional information. The only way to make new request to work again, is to refresh the wallet (cmd+r)

Ganbin commented 1 year ago

In 1.8.2 the getWallets with include_data": true is now working for my wallet with a lot of data in my DID wallet. The on chain NFTs still make the chia_getNFTs method to fail.

wjblanke commented 6 days ago

Are you still having this issue with 2.4.1?