From 92642644db4ad0f8cb8fcde91a79eaa851baa296 Mon Sep 17 00:00:00 2001 From: Johnny Graettinger Date: Thu, 5 Sep 2024 15:43:51 -0500 Subject: [PATCH] go/runtime: fix race in connectorProxy Don't tell the client about a connector proxy ID we haven't actually started or indexed yet. --- go/runtime/connector_proxy.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/go/runtime/connector_proxy.go b/go/runtime/connector_proxy.go index 5e8dd77492..dc68ae3f60 100644 --- a/go/runtime/connector_proxy.go +++ b/go/runtime/connector_proxy.go @@ -45,10 +45,6 @@ func (s *connectorProxy) ProxyConnectors(stream pr.ConnectorProxy_ProxyConnector // Unique id for this proxy, that we'll pass back to the client. var id = fmt.Sprintf("connector-proxy-%d", time.Now().UnixNano()) - _ = stream.Send(&pr.ConnectorProxyResponse{ - Address: s.address, - ProxyId: id, - }) svc, err := bindings.NewTaskService( pr.TaskServiceConfig{ AllowLocal: s.host.Config.Flow.AllowLocal, @@ -76,6 +72,12 @@ func (s *connectorProxy) ProxyConnectors(stream pr.ConnectorProxy_ProxyConnector svc.Drop() }() + // Now that we've indexed `id`, tell the client about it. + _ = stream.Send(&pr.ConnectorProxyResponse{ + Address: s.address, + ProxyId: id, + }) + // Block until we read EOF, signaling a graceful shutdown. for { if _, err = stream.Recv(); err == nil {