{"record":{"id":"7f8bc434d90edf97","repo":"apache/beam","slug":"failed-to-create-state-client-v","errorCode":null,"errorMessage":"failed to create state client %v","messagePattern":"failed to create state client (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/harness/statemgr.go","lineNumber":678,"sourceCode":"\t\tc.forceRecreate = nil\n\t}\n\t// Cancelling context after forcing recreation to ensure closedErr is set.\n\tc.cancelFn()\n\tc.mu.Unlock()\n}\n\nfunc newStateChannel(ctx context.Context, port exec.Port) (*StateChannel, error) {\n\tctx, cancelFn := context.WithCancel(ctx)\n\tcc, err := dial(ctx, port.URL, \"state\", 15*time.Second)\n\tif err != nil {\n\t\tcancelFn()\n\t\treturn nil, errors.Wrapf(err, \"failed to connect to state service %v\", port.URL)\n\t}\n\tclient, err := fnpb.NewBeamFnStateClient(cc).State(ctx)\n\tif err != nil {\n\t\tcc.Close()\n\t\tcancelFn()\n\t\treturn nil, errors.Wrapf(err, \"failed to create state client %v\", port.URL)\n\t}\n\treturn makeStateChannel(ctx, port.URL, client, func() {\n\t\tcc.Close()\n\t\tcancelFn()\n\t}), nil\n}\n\nfunc makeStateChannel(ctx context.Context, id string, client stateClient, cancelFn context.CancelFunc) *StateChannel {\n\tret := &StateChannel{\n\t\tid:        id,\n\t\tclient:    client,\n\t\trequests:  make(chan *fnpb.StateRequest, 10),\n\t\tresponses: make(map[string]chan<- *fnpb.StateResponse),\n\t\tcancelFn:  cancelFn,\n\t\tDoneCh:    ctx.Done(),\n\t}\n\tgo ret.read(ctx)\n\tgo ret.write(ctx)","sourceCodeStart":660,"sourceCodeEnd":696,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/harness/statemgr.go#L660-L696","documentation":"After a successful dial, newStateChannel opens the BeamFnState bidirectional stream via fnpb.NewBeamFnStateClient(cc).State(ctx). If the stream cannot be established, the connection is closed and this wrapped error is returned with the port URL. The endpoint accepted the TCP/gRPC handshake but the State RPC itself failed.","triggerScenarios":"The state service rejecting or failing the State() streaming RPC — e.g. server does not implement BeamFnState, protocol version mismatch, request canceled due to the 15s context deadline, or runner-side error at stream setup.","commonSituations":"Runner/SDK version skew where the state service API differs, runner closing connections during shutdown, resource exhaustion on the runner preventing new streams.","solutions":["Align Beam SDK and runner versions (protocol skew is the most common cause).","Check runner logs for errors accepting the State stream.","Inspect the inner error for context.DeadlineExceeded and retry the bundle/job if transient.","If persistent, report to the runner maintainer with the wrapped error and endpoint."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure versions match\nif runtimeVersion != runnerApiVersion { return fmt.Errorf(\"SDK %s vs runner %s mismatch\", runtimeVersion, runnerApiVersion) }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"failed to create state client\") {\n    time.Sleep(time.Second)\n    return retryOpen(ctx, port) // transient stream-setup failure\n}","preventionTips":["Pin matching Beam SDK and runner versions","Watch runner logs for stream setup errors","Retry transient bundle failures at the runner level"],"tags":["go","grpc","beam","rpc"],"backgroundTag":"api-error-response","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}