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

Show network error on unexpected disconnect #88

Merged
merged 1 commit into from
Aug 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions cmd/coder/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ func runCommand(ctx context.Context, envName string, command string, args []stri
Env: cmdEnv,
})
if err != nil {
var closeErr websocket.CloseError
if xerrors.As(err, &closeErr) {
return xerrors.Errorf("network error, is %q online?", envName)
}
return err
}

Expand Down Expand Up @@ -157,10 +161,14 @@ func runCommand(ctx context.Context, envName string, command string, args []stri
}
}()
err = process.Wait()
if err != nil && xerrors.Is(err, ctx.Err()) {
return xerrors.Errorf("network error, is %q online?", envName)
if err != nil {
var closeErr websocket.CloseError
if xerrors.Is(err, ctx.Err()) || xerrors.As(err, &closeErr) {
return xerrors.Errorf("network error, is %q online?", envName)
}
return err
}
return err
return nil
}

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