WalletConnect / walletconnect-monorepo

WalletConnect Monorepo
Apache License 2.0
1.26k stars 629 forks source link

Error in response causes new requests to not be processed. #4707

Open antondalgren opened 6 days ago

antondalgren commented 6 days ago

Describe the bug If there is an error in the SDK after we have sent a response to a request, it is not possible to process a new request until that one has expired.

If any of these send methods throws an error, the cleanup method isn't called and the engine will not have it's state changed from active to idle and thus it will block any new request from being processed. https://github.com/WalletConnect/walletconnect-monorepo/blob/5899f274aaf97f0ae0726d227474655edb526f2e/packages/sign-client/src/controllers/engine.ts#L516-L520

I have experienced this error to be thrown locally: https://github.com/WalletConnect/walletconnect-monorepo/blob/5899f274aaf97f0ae0726d227474655edb526f2e/packages/sign-client/src/controllers/engine.ts#L1248-L1249

I'm not sure if the intention is that we are supposed to handle the error in this case or if there is something to be added to the SDK to ensure that the message has been transmitted successfully.

SDK Version (if relevant)

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

Error Logs:

 DEBUG  {"context": "core/relayer", "level": 20, "msg": "Incoming Relay Payload", "time": 1719495803262}
 DEBUG  {"context": "core/relayer", "level": 20, "msg": "Emitting Relayer Payload", "time": 1719495803264}
 DEBUG  {"context": "core/history", "level": 20, "msg": "Setting JSON-RPC request history record", "time": 1719495803275}
 LOG  {"context": "core/history", "level": 30, "msg": "Emitting history_created", "time": 1719495803281}
 DEBUG  {"context": "core/history", "event": "history_created", "level": 20, "record": {"chainId": undefined, "expiry": 1722087803, "id": 1719495803137475, "request": {"method": "wc_sessionRequest", "params": [Object]}, "topic": "3667ab5e15ad9f7ef0e90b1e30430982dada5483458ce8b4c6ba35698d8f1c88"}, "time": 1719495803281, "type": "event"}
 INFO  {"context": "client"} Request queue starting with 1 requests
 DEBUG  {"context": "client"} Getting value
 DEBUG  {"context": "client"} Getting value
 DEBUG  {"context": "client"} Getting value
 LOG  {"context": "core/verify-api", "level": 30, "msg": "resolving attestation: baf071a31eda0e67bc4471514eab8ac0e39fddba27a782e26994a6d78bf44cdd from url: https://verify.walletconnect.com", "time": 1719495803287}
 INFO  {"context": "client"} Verify context: {"verified":{"verifyUrl":"https://verify.walletconnect.com","validation":"UNKNOWN","origin":"UNKNOWN"}}
 LOG  {"context": "core/expirer", "level": 30, "msg": "Emitting expirer_created", "time": 1719495803386}
 DEBUG  {"context": "core/expirer", "data": {"expiration": {"expiry": 1719496103, "target": "id:1719495803137475"}, "target": "id:1719495803137475"}, "event": "expirer_created", "level": 20, "time": 1719495803387, "type": "event"}
 DEBUG  {"context": "client"} Setting value
 DEBUG  {"context": "client"} Getting value
 DEBUG  {"context": "client"} Getting value
 DEBUG  {"context": "core/history", "level": 20, "msg": "Getting record", "time": 1719495807790}
 ERROR  {"context": "client"} sendError() -> history.get(3667ab5e15ad9f7ef0e90b1e30430982dada5483458ce8b4c6ba35698d8f1c88, 1719495803137475) failed
 ERROR  {"context": "client"} No matching key. history: 1719495803137475
linear[bot] commented 6 days ago

CR-96 Error in response causes new requests to not be processed.

antondalgren commented 2 days ago

From the logs, it looks like the call to persist fails/is slow since later when trying to read from history it fails to find the entry. https://github.com/WalletConnect/walletconnect-monorepo/blob/5899f274aaf97f0ae0726d227474655edb526f2e/packages/core/src/controllers/history.ts#L88