Skip to content

feat(websockets): add isready(ws) to poll for buffered messages#1261

Open
quinnj wants to merge 1 commit into
masterfrom
jq-ws-isready
Open

feat(websockets): add isready(ws) to poll for buffered messages#1261
quinnj wants to merge 1 commit into
masterfrom
jq-ws-isready

Conversation

@quinnj
Copy link
Copy Markdown
Member

@quinnj quinnj commented May 30, 2026

Closes #1169.

Adds Base.isready(ws::WebSocket), which returns true when a complete message is buffered and ready to read with receive(ws) without blocking — a public, non-blocking way to check for incoming WebSocket messages. Previously this was only reachable by poking the internal read channel.

HTTP.WebSockets.open(url) do ws
    if isready(ws)
        msg = HTTP.WebSockets.receive(ws)   # guaranteed not to block
    end
end

isready semantics match Channel: false doesn't imply the connection is closed (more may arrive), and messages buffered before close stay isready and are returned by receive before it throws. Includes a docstring + integration test.

🤖 Generated with Claude Code

Closes #1169. `Base.isready(ws::WebSocket)` returns true when a complete message
is buffered and `receive(ws)` won't block — a public, non-blocking way to check
for incoming WebSocket messages (previously only reachable via the internal
readchannel). Includes a docstring and an integration test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.36%. Comparing base (f9d62af) to head (9646ba9).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1261   +/-   ##
=======================================
  Coverage   84.36%   84.36%           
=======================================
  Files          28       28           
  Lines       10689    10690    +1     
=======================================
+ Hits         9018     9019    +1     
  Misses       1671     1671           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC] convenience function to check if websocket has incoming messages

1 participant