Skip to content

Avoid returning 0, nil in netConn.Read #367

Closed
@MarcoPolo

Description

@MarcoPolo

When we reach the end of the frame we currently return 0, nil (https://github.com/nhooyr/websocket/blob/master/netconn.go#L118). The io.Reader docs discourage this:

Implementations of Read are discouraged from returning a zero byte count with a nil error, except when len(p) == 0.

This seems to have confused other folks as well: #353

My recommendation is we don't return 0, nil and instead block until we get data or a proper error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions