mirror of
https://github.com/golang/go
synced 2024-11-18 16:04:44 -07:00
internal/lsp/lsprpc: wait for the handshake before running clientConn
By running the client connection before the forwarder-remote handshake completes, we introduce a race in the TestDebugInfoLifecycle: the editor may connect and initialize before the handshake, and assertions on the debug state fail. Requiring that the handshake complete before running the client connection fixes this flakiness. It also seems like a good thing to have the handshake complete before proceeding with any LSP. Fixes golang/go#37444 Change-Id: I07187797b4759bcaf99f5b0a0b3cd7ac7de34f43 Reviewed-on: https://go-review.googlesource.com/c/tools/+/220903 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
df82bb964a
commit
45849e8256
@ -218,9 +218,8 @@ func (f *Forwarder) ServeStream(ctx context.Context, stream jsonrpc2.Stream) err
|
||||
g.Go(func() error {
|
||||
return serverConn.Run(ctx)
|
||||
})
|
||||
g.Go(func() error {
|
||||
return clientConn.Run(ctx)
|
||||
})
|
||||
// Don't run the clientConn yet, so that we can complete the handshake before
|
||||
// processing any client messages.
|
||||
|
||||
// Do a handshake with the server instance to exchange debug information.
|
||||
index := atomic.AddInt64(&serverIndex, 1)
|
||||
@ -249,6 +248,10 @@ func (f *Forwarder) ServeStream(ctx context.Context, stream jsonrpc2.Stream) err
|
||||
},
|
||||
clientID: hresp.ClientID,
|
||||
})
|
||||
g.Go(func() error {
|
||||
return clientConn.Run(ctx)
|
||||
})
|
||||
|
||||
return g.Wait()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user