Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion components/gitpod-cli/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ USER gitpod
}
}

openCmd.RunE(cmd, []string{v.File})
err = openCmd.RunE(cmd, []string{v.File})
if err != nil {
return err
}
}
return openCmd.RunE(cmd, []string{".gitpod.yml"})
},
Expand Down
17 changes: 14 additions & 3 deletions components/gitpod-cli/cmd/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var openCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
// TODO(ak) use NotificationService.NotifyActive supervisor API instead

ctx, cancel := context.WithTimeout(cmd.Context(), 5*time.Second)
ctx, cancel := context.WithTimeout(cmd.Context(), 10*time.Second)
defer cancel()

client, err := supervisor.New(ctx)
Expand Down Expand Up @@ -57,12 +57,23 @@ var openCmd = &cobra.Command{

if wait {
pargs = append(pargs, "--wait")
ctx = cmd.Context()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: there're ctx used before this line, like client.WaitForIDEReady(ctx). If a use passed --wait flag, it will not wait IDE to be ready after '10 seconds of not ready' then returns an error.

(But the original code has this issue as well, so I'm not sure if this is an intended feature)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mustard-mh looking at the code again, it seems fine to use the timeout-enabled context everywhere besides the final call to the editor binary, since we want to be able to time out on the other operations that are not expected to run potentially indefinitely.

Running the following inside the gitpod-cli directory seems to behave as expected, even when taking more than 10s to close the file:

go run . open --wait main.go 

}
c := exec.CommandContext(cmd.Context(), pcmd, append(pargs[1:], args...)...)
c := exec.CommandContext(ctx, pcmd, append(pargs[1:], args...)...)
c.Stdin = os.Stdin
c.Stdout = os.Stdout
c.Stderr = os.Stderr
return c.Run()
time.Sleep(10 * time.Second)
err = c.Run()
if err != nil {
if ctx.Err() != nil {
return xerrors.Errorf("editor failed to open in time: %w", ctx.Err())
}

return xerrors.Errorf("editor failed to open: %w", err)
}

return nil
},
}

Expand Down
Loading