Skip to content

Commit 50b118c

Browse files
committed
Properly time out gp open
1 parent 9c06e5c commit 50b118c

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-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: 14 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,23 @@ 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+
time.Sleep(10 * time.Second)
67+
err = c.Run()
68+
if err != nil {
69+
if ctx.Err() != nil {
70+
return xerrors.Errorf("editor failed to open in time: %w", ctx.Err())
71+
}
72+
73+
return xerrors.Errorf("editor failed to open: %w", err)
74+
}
75+
76+
return nil
6677
},
6778
}
6879

0 commit comments

Comments
 (0)