Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit a08956f

Browse files
committed
Show network error on unexpected disconnect
1 parent 6316e07 commit a08956f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Diff for: cmd/coder/shell.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ func runCommand(ctx context.Context, envName string, command string, args []stri
126126
Env: cmdEnv,
127127
})
128128
if err != nil {
129+
var closeErr websocket.CloseError
130+
if xerrors.As(err, &closeErr) {
131+
return xerrors.Errorf("network error, is %q online?", envName)
132+
}
129133
return err
130134
}
131135

@@ -157,10 +161,14 @@ func runCommand(ctx context.Context, envName string, command string, args []stri
157161
}
158162
}()
159163
err = process.Wait()
160-
if err != nil && xerrors.Is(err, ctx.Err()) {
161-
return xerrors.Errorf("network error, is %q online?", envName)
164+
if err != nil {
165+
var closeErr websocket.CloseError
166+
if xerrors.Is(err, ctx.Err()) || xerrors.As(err, &closeErr) {
167+
return xerrors.Errorf("network error, is %q online?", envName)
168+
}
169+
return err
162170
}
163-
return err
171+
return nil
164172
}
165173

166174
func heartbeat(ctx context.Context, c *websocket.Conn, interval time.Duration) {

0 commit comments

Comments
 (0)