- Do not fail NextWriter when close of previous writer fails.
- Replace closeSent field with mutex protected writeErr. Set writeErr on
any error writing to underlying network connection. Check and return
writeErr before attempting to write to network connection. Check
writeErr in NextWriter so application can detect failed connection
before attempting to write.
- Do not close underlying network connection on error.
- Move message writing state and method flushFrame from Conn to
messageWriter. This makes error code paths (and the code in general)
easier to understand.
- Add messageWriter field err to latch errors in messageWriter.
Bonus: Improve test coverage.
Update documentation to explicitly state that applications must break out of a
read loop on error.
Detect application read loops spinning on a failed connection and panic.
Detect concurrent writes and panic. The detection is best-effort.
Update documentation to state that connections respond to close frames.
- Use new closeError type for reporting close frames to the application.
- Use closeError with code 1006 when the peer closes connection without
sending a close frame. The error io.ErrUnexpectedEOF was used
previously. This change helps developers distinguish abnormal closure
and an unexpected EOF in the JSON parser.
- Modify data message reader to return io.ErrUnexpectedEOF if a close
message is received before the final frame of the message.
- Modify NextReader to return io.ErrUnexpectedEOF if underlying
connection returns io.EOF before a close message.