Skip to content

Commit 28942bd

Browse files
Properly time out gp open (#20378)
* Properly time out `gp open` * on the Edge of Sleep™
1 parent 9c06e5c commit 28942bd

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

components/gitpod-cli/cmd/init.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ USER gitpod
126126
}
127127
}
128128

129-
openCmd.RunE(cmd, []string{v.File})
129+
err = openCmd.RunE(cmd, []string{v.File})
130+
if err != nil {
131+
return err
132+
}
130133
}
131134
return openCmd.RunE(cmd, []string{".gitpod.yml"})
132135
},

components/gitpod-cli/cmd/open.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var openCmd = &cobra.Command{
2626
RunE: func(cmd *cobra.Command, args []string) error {
2727
// TODO(ak) use NotificationService.NotifyActive supervisor API instead
2828

29-
ctx, cancel := context.WithTimeout(cmd.Context(), 5*time.Second)
29+
ctx, cancel := context.WithTimeout(cmd.Context(), 10*time.Second)
3030
defer cancel()
3131

3232
client, err := supervisor.New(ctx)
@@ -57,12 +57,22 @@ var openCmd = &cobra.Command{
5757

5858
if wait {
5959
pargs = append(pargs, "--wait")
60+
ctx = cmd.Context()
6061
}
61-
c := exec.CommandContext(cmd.Context(), pcmd, append(pargs[1:], args...)...)
62+
c := exec.CommandContext(ctx, pcmd, append(pargs[1:], args...)...)
6263
c.Stdin = os.Stdin
6364
c.Stdout = os.Stdout
6465
c.Stderr = os.Stderr
65-
return c.Run()
66+
err = c.Run()
67+
if err != nil {
68+
if ctx.Err() != nil {
69+
return xerrors.Errorf("editor failed to open in time: %w", ctx.Err())
70+
}
71+
72+
return xerrors.Errorf("editor failed to open: %w", err)
73+
}
74+
75+
return nil
6676
},
6777
}
6878

0 commit comments

Comments
 (0)