GRI-1912: close the WebSocket gracefully on approve/pend/reject #125
No reviewers
Labels
No labels
Area/Backend
Area/Database
Area/Docs
Area/Frontend
Area/Infra
Area/Security
Area/Tests
Area/Tooling
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Lang/Python
Lang/Rust
Lang/Shell
Lang/SQL
Lang/TypeScript
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Routing
Auto
Routing
Hold
Routing
Human
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Grimoirix/grimoire-of-digital-signage!125
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/GRI-1912-ws-graceful-close"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Closes grimoire-of-digital-signage#123.
approve(),pend()andreject()incrates/server/src/ws.rswrote their final frame and thenreturned, letting the
WebSocket(and its TCP stream) drop with noclosing handshake. Linux answers
close()with unread bytes still in thereceive buffer with a TCP RST instead of a FIN, and a reset can discard
data the peer already received but had not yet read off its socket
buffer — including the just-written
Approvedframe and its one-shottoken. The device is then locked out: the token row has already been
consumed, so every later reconnect gets
Rejected: already enrolled on another connection.close_gracefully(): sends an explicit WebSocket Close frame,then drains incoming frames until EOF or a 5s timeout, so the socket
empties any unread input before it drops and the OS does a normal FIN
close instead of an RST.
approve(),pend()(after registration isread) and
reject().Test plan
cargo build -p server --testscleanan_approved_device_s_reconnect_ends_with_a_close_frame_not_a_resetin
crates/server/tests/ws_integration.rs, asserting the server sendsan explicit Close frame on this path (the RST race itself is
timing/OS-dependent and not reliably reproducible in an integration
test; this pins the observable half of the fix)
./scripts/local-gates.sh --rust-only: every gate passed