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
Manually run chainweaver native app
Use kda wallet-sign to issue signing commands and raise the QuickSign modal
Close it with Reject
Confirm kda acknowledges the rejection.
Repeat for X button.
Repeat for Esc key.
Repeat again for Reject, X, and Esc.
Confirm UI is still responsive to switching tabs.
Issue another kda wallet-sign and accept.
Confirm UI is still responsive.
One more kda wallet-sign and Reject and confirm UI responsive for good measure.
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
kda wallet-sign
to issue signing commands and raise the QuickSign modalReject
kda
acknowledges the rejection.X
button.Esc
key.Reject
,X
, andEsc
.kda wallet-sign
and accept.kda wallet-sign
andReject
and confirm UI responsive for good measure.