Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Based on #195 but zero-copy] Log ws message on parsing error to Message enum #204

Merged
merged 5 commits into from
Feb 14, 2024

Conversation

ryo33
Copy link
Contributor

@ryo33 ryo33 commented Feb 14, 2024

As the title, this is based on #195, but zero-copy.

Also, it changes from doing serde_json::from_slice(&data.into_data()) to doing serde_json::from_str(&text) of WsMessage::Text(text). Other variants of WsMessage are handled as follows:

  • Ping and Pong: Ignored
  • Bytes and Frames: Ignored
  • Close: Ends the stream

src/conn.rs Outdated
Comment on lines 158 to 159
// ignore pings
Poll::Pending
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might still have more work to do so we either need to wake here before returning pending are put the ws poll in a loop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, i've fixed it!

@MOZGIII
Copy link
Contributor

MOZGIII commented Feb 14, 2024

Is it safe to ignore the bytes and frames though?

@mattsse mattsse merged commit 3489675 into mattsse:main Feb 14, 2024
7 checks passed
@ryo33
Copy link
Contributor Author

ryo33 commented Feb 15, 2024

Is it safe to ignore the bytes and frames though?

Ignoring Frame is safe because we should not get it when reading a message as snapview/tungstenite-rs#250.

IMO ignoring Bytes is also safe because cdp is a JSON-based protocol and I suppose it uses only the text type of frame.

@MOZGIII
Copy link
Contributor

MOZGIII commented Feb 15, 2024

CDP actually can stream the responses - which would suggest using the advanced websocket capabilities - but I checked and it indeed only uses text with data embedded as base64.

See:

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.

3 participants