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

netConn and msgReader should return io.EOF identically instead of wrapped #504

Open
spikecurtis opened this issue Dec 17, 2024 · 0 comments
Labels

Comments

@spikecurtis
Copy link

*bufio.Scanner and other consumers of io.Reader interface expect to receive io.EOF identically when reading to the end of a file/stream.

From the io package:

// EOF is the error returned by Read when no more input is available.
// (Read must return EOF itself, not an error wrapping EOF,
// because callers will test for EOF using ==.)
// Functions should return EOF only to signal a graceful end of input.
// If the EOF occurs unexpectedly in a structured data stream,
// the appropriate error is either [ErrUnexpectedEOF] or some other error
// giving more detail.
var EOF = errors.New("EOF")

We currently wrap EOF along with any other error when reading from netConn or msgReader. Instead, we should return io.EOF identically to conform with the io.Reader spec.

spikecurtis added a commit to coder/coder that referenced this issue Dec 18, 2024
Migrates us to `coder/websocket` v1.8.12 rather than `nhooyr/websocket` on an older version.

Works around coder/websocket#504 by adding an explicit test for `xerrors.Is(err, io.EOF)` where we were previously getting `io.EOF` from the netConn.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant