Skip to content

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

Merged
quinnj merged 1 commit into
masterfrom
jq-ws-isready
Jun 1, 2026
Merged

feat(websockets): add isready(ws) to poll for buffered messages#1261
quinnj merged 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

@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.37%. Comparing base (83f4873) to head (560ccf7).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1261      +/-   ##
==========================================
- Coverage   84.51%   84.37%   -0.14%     
==========================================
  Files          28       28              
  Lines       10690    10691       +1     
==========================================
- Hits         9035     9021      -14     
- Misses       1655     1670      +15     

☔ 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.

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>
@quinnj quinnj merged commit 1c6219a into master Jun 1, 2026
12 of 14 checks passed
@quinnj quinnj deleted the jq-ws-isready branch June 1, 2026 17:50
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