4
4
"context"
5
5
"database/sql"
6
6
"encoding/json"
7
- "errors"
8
7
"fmt"
9
8
"io"
10
9
"net"
@@ -521,23 +520,23 @@ func convertWorkspaceAgent(dbAgent database.WorkspaceAgent, agentUpdateFrequency
521
520
}
522
521
523
522
// wsNetConn wraps net.Conn created by websocket.NetConn(). Cancel func
524
- // is called ifio.EOF is encountered.
523
+ // is called ifa read or write error is encountered.
525
524
type wsNetConn struct {
526
525
cancel context.CancelFunc
527
526
net.Conn
528
527
}
529
528
530
529
func (c * wsNetConn )Read (b []byte ) (n int ,err error ) {
531
530
n ,err = c .Conn .Read (b )
532
- if errors . Is ( err , io . EOF ) {
531
+ if err != nil {
533
532
c .cancel ()
534
533
}
535
534
return n ,err
536
535
}
537
536
538
537
func (c * wsNetConn )Write (b []byte ) (n int ,err error ) {
539
538
n ,err = c .Conn .Write (b )
540
- if errors . Is ( err , io . EOF ) {
539
+ if err != nil {
541
540
c .cancel ()
542
541
}
543
542
return n ,err
@@ -549,8 +548,8 @@ func (c *wsNetConn) Close() error {
549
548
}
550
549
551
550
// websocketNetConn wraps websocket.NetConn and returns a context that
552
- // is tied to the parent context and the lifetime of the conn.A io.EOF
553
- //error during read or write will cancel the context, but not close the
551
+ // is tied to the parent context and the lifetime of the conn.Any error
552
+ // during read or write will cancel the context, but not close the
554
553
// conn. Close should be called to release context resources.
555
554
func websocketNetConn (ctx context.Context ,conn * websocket.Conn ,msgType websocket.MessageType ) (context.Context , net.Conn ) {
556
555
ctx ,cancel := context .WithCancel (ctx )