coder / coder/websocket

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

Open
#504 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
5.5k
Forks
372
PR merge metrics
No merged PRs in 30d

Description

[*bufio.Scanner](https://pkg.go.dev/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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.