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