fix(mint): handle websocket disconnect frames cleanly#1014
Merged
a1denvalu3 merged 1 commit intoMay 28, 2026
Merged
Conversation
Signed-off-by: b-l-u-e <8102260+blue@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1014 +/- ##
==========================================
+ Coverage 74.90% 74.99% +0.08%
==========================================
Files 99 111 +12
Lines 11685 12066 +381
==========================================
+ Hits 8753 9049 +296
- Misses 2932 3017 +85 ☔ View full report in Codecov by Sentry. |
a1denvalu3
approved these changes
May 21, 2026
Collaborator
|
Very nice PR thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While reviewing and testing
fix(websocket): support generic quote kinds, websocket integration tests passed but produced noisy teardown errors in the mint logs. This PR fixes the underlying disconnect handlingRoot cause:
LedgerEventClientManager.start()treated awebsocket.disconnectframe as “no text, keep looping” instead of exiting. On server shutdown (ASGI1012), the loop calledreceive()again, which raisedRuntimeError, triggered a double-close, and loggedERROR | Exception in ASGI application.Motivation
While running websocket subscription tests for the generic quote kinds PR:
All tests passed (
3 passed), but pytest teardown produced alarming mint logs:Before (broken teardown)
The disconnect frame was received, but the receive loop ignored it and called
receive()again.After (clean teardown)
No exception, no double-close, no ASGI error.
Changes
cashu/mint/events/client.py— exit the receive loop when awebsocket.disconnectframe is received (raiseWebSocketDisconnectwith the frame's code).cashu/mint/router.py— unify websocket endpoint cleanup:finallywebsocket.close()if the socket is not already disconnectedtests/mint/test_mint_websocket_protocol.py— add regression test for disconnect frame handling