Skip to content

Commit

Permalink
🐛 Adding ability to error on initialize failed and capture command is…
Browse files Browse the repository at this point in the history
…sue (#277)

Signed-off-by: Shawn Hurley <[email protected]>
  • Loading branch information
shawn-hurley authored Aug 3, 2023
1 parent 7ebd2f5 commit 3fab15f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion provider/internal/java/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide
go func() {
err := cmd.Start()
if err != nil {
fmt.Printf("here cmd failed- %v", err)
cancelFunc()
returnErr = err
log.Error(err, "unable to start lsp command")
return
}
}()
rpc := jsonrpc2.NewConn(jsonrpc2.NewHeaderStream(stdout, stdin), log)
Expand All @@ -264,6 +267,8 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide
//TODO: we need to pipe the ctx further into the stream header and run.
// basically it is checking if done, then reading. When it gets EOF it errors.
// We need the read to be at the same level of selection to fully implment graceful shutdown
cancelFunc()
returnErr = err
return
}
}()
Expand Down
2 changes: 1 addition & 1 deletion provider/internal/java/service_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (p *javaServiceClient) initialization() {
}

var result protocol.InitializeResult
for {
for i:=0; i < 10; i++ {
if err := p.rpc.Call(p.ctx, "initialize", params, &result); err != nil {
p.log.Error(err, "initialize failed")
continue
Expand Down

0 comments on commit 3fab15f

Please sign in to comment.