{"record":{"id":"703ecaf42d0ac3e2","repo":"apache/beam","slug":"statechannel-v-send-v-context-canceled","errorCode":null,"errorMessage":"StateChannel[%v].Send(%v): context canceled","messagePattern":"StateChannel\\[(.+?)\\]\\.Send\\((.+?)\\): context canceled","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/harness/statemgr.go","lineNumber":799,"sourceCode":"\n\tch := make(chan *fnpb.StateResponse, 1)\n\tc.mu.Lock()\n\tif c.closedErr != nil {\n\t\tdefer c.mu.Unlock()\n\t\treturn nil, errors.Wrapf(c.closedErr, \"StateChannel[%v].Send(%v): channel closed due to: %v\", c.id, id, c.closedErr)\n\t}\n\tc.responses[id] = ch\n\tc.mu.Unlock()\n\n\tc.requests <- req\n\n\tvar resp *fnpb.StateResponse\n\tselect {\n\tcase resp = <-ch:\n\tcase <-c.DoneCh:\n\t\tc.mu.Lock()\n\t\tdefer c.mu.Unlock()\n\t\treturn nil, errors.Wrapf(c.closedErr, \"StateChannel[%v].Send(%v): context canceled\", c.id, id)\n\t}\n\tif resp.Error != \"\" {\n\t\treturn nil, errors.New(resp.Error)\n\t}\n\treturn resp, nil\n}\n","sourceCodeStart":781,"sourceCodeEnd":806,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/harness/statemgr.go#L781-L806","documentation":"StateChannel.Send waits for the response future; if the channel's DoneCh fires (the stream was closed) before a response arrives, Send returns this wrapped error carrying the underlying closedErr. The message says \"context canceled\" because the send effectively aborted — the stream ended without answering the request.","triggerScenarios":"Sending a state request and, while blocked on the per-request response channel, the receive loop terminates (EOF, gRPC error, runner shutdown), closing DoneCh before the response is delivered.","commonSituations":"Runner terminating mid-bundle, state stream dropped by network interruption, harness shutdown racing outstanding state requests, gRPC server rejecting an in-flight request and tearing down the stream.","solutions":["Look at the wrapped closedErr to find why the stream closed and fix that root cause.","Verify the runner did not crash; restart the job if the runner died mid-bundle.","Check idle/deadline timeouts on proxies between the harness and the state service.","Retry the failing bundle; use runner retry policies to mask transient stream drops."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"context canceled\") {\n    return retryable(err) // stream ended before response; let runner retry the bundle\n}","preventionTips":["Check the wrapped closedErr for the true cause","Avoid harness shutdown while state requests are in flight","Set adequate timeouts on proxies between worker and runner"],"tags":["go","grpc","beam","context-canceled"],"backgroundTag":"request-timeout","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"}