kadena-io / chainweaver

Kadena Chainweaver desktop wallet and web-based playground for Pact
https://chainweaver.kadena.network
60 stars 29 forks source link

Deduplicate response-sending events in quickSign #792

Closed imalsogreg closed 1 year ago

imalsogreg commented 1 year ago

Our code for interpreting HTTP requests relies on MVarHandler, which assumes one response is generated per request. When this assumption is violated, MVar invariants get broken and we see deadlocks.

For reasons we still don't understand, any event that causes the QuickSign modal to close without issuing a positive signal to sign its transaction produces an extra modal-close event.

Each modal-close event gets mapped to an HTTP response, and this PUTs to the same MVar twice without an intervening TAKE.

This commit fixes the issue by simply deduplicating close events.

A more principled solution would have removed the source of the duplicated close events upstream, but it was not trivial to figure out. So we have a stopgap.

Testing done