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

Commit 13fb3ca

Browse files
authored
Merge pull request #88 from cdr/close-err
Show network error on unexpected disconnect
2 parents 6316e07 + a08956f commit 13fb3ca

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

cmd/coder/shell.go

Lines changed: 11 additions & 3 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy