8000 fix(gateway): stop delivering buffered frames after the transport is closed by topi314 · Pull Request #634 · disgoorg/disgo · GitHub
[go: up one dir, main page]

Skip to content

fix(gateway): stop delivering buffered frames after the transport is closed - #634

Merged
topi314 merged 2 commits into
masterfrom
fix/gateway-stale-frames-after-close
Oct 24, 2026
Merged

topi314 merged 2 commits into
masterfrom
fix/gateway-stale-frames-after-close

Conversation

@topi314
@topi314 topi314 commented Oct 23, 2026
Copy link
Copy Markdown
Member

websocket.Conn keeps returning frames it already buffered after Close. A listen goroutine of a replaced connection could therefore still handle e.g. an invalid session from the old connection and clear the session the new connection is resuming with, crashing on the nil SessionID once RESUMED arrives.

Fixes #631

…closed

websocket.Conn keeps returning frames it already buffered after Close. A listen goroutine of a replaced connection could therefore still handle e.g. an invalid session from the old connection and clear the session the new connection is resuming with, crashing on the nil SessionID once RESUMED arrives.

Fixes #631

Co-authored-by: Saiop68 <sairajpatwardhan399@gmail.com>
@topi314
topi314 force-pushed the fix/gateway-stale-frames-after-close branch from f1c7b09 to a028b5f Compare October 23, 2026 18:39
@topi314 topi314 self-assigned this Oct 23, 2026
SessionID, ResumeURL and LastSequenceReceived were pointers on the config that were dereferenced without nil checks and read and written from multiple goroutines without synchronization. The session state now lives in its own struct on the gateway, guarded by sessionMu, with empty values meaning there is nothing to resume. The config fields only provide the initial session, so the config is no longer mutated after New. The public getters keep returning nil when no value is set.
@topi314
topi314 force-pushed the fix/gateway-stale-frames-after-close branch from 0296395 to 51bd639 Compare October 23, 2026 20:14
@topi314
topi314 merged commit 2ad9e53 into master Oct 24, 2026
7 checks passed
@topi314
topi314 deleted the fix/gateway-stale-frames-after-close branch October 24, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

panic: runtime error: invalid memory address or nil pointer dereference in gateway.listen on EventResumed (gateway.go:658)

1 participant

0