Repository navigation
expose when data was last received from the websocket client - #53
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bentsku
added this pull request to stack #54
October 7, 2026 00:54
bentsku
marked this pull request as ready for review
October 7, 2026 09:41
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.
Motivation
A server that implements an idle timeout has to know when the client was last active. The listener can track the messages it receives, but not the control frames: the twisted channel answers pings itself on the reactor thread, so a client that keeps its connection alive with pings looks idle to the listener.
Changes
WebSocketAdapter.last_received_atandWebSocket.last_received_at: thetime.monotonic()time at which data was last received from the client, or at which the connection was created if nothing was received yet.WebSocketChannelupdates it on everydataReceived, so pings, pongs and partial frames count too.Testing
test_last_received_at_message(twisted and asgi): the timestamp after receiving a message must be later than the time the client sent it.test_last_received_at_ping(twisted): a ping alone must move the timestamp forward.dataReceiveddoesn't update the timestamp. The full suite passes (195 tests) and lint is clean.🤖 Generated with Claude Code