{"record":{"id":"fd6bc5a51d514656","repo":"t8y2/dbx","slug":"wait-for-rocketmq-broker-registration-w","errorCode":null,"errorMessage":"wait for RocketMQ broker registration: %w","messagePattern":"wait for RocketMQ broker registration: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rocketmq/connection.go","lineNumber":199,"sourceCode":"\t}\n\tvar lastErr error\n\tfor {\n\t\tclusterInfo, err := examine(ctx)\n\t\tif err == nil && hasMasterBroker(clusterInfo) {\n\t\t\treturn clusterInfo, nil\n\t\t}\n\t\tif err != nil {\n\t\t\tlastErr = err\n\t\t}\n\n\t\ttimer := time.NewTimer(pollInterval)\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\ttimer.Stop()\n\t\t\tif lastErr != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"wait for RocketMQ broker registration after %v: %w\", lastErr, ctx.Err())\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"wait for RocketMQ broker registration: %w\", ctx.Err())\n\t\tcase <-timer.C:\n\t\t}\n\t}\n}\n\nfunc hasMasterBroker(info *admin.ClusterInfo) bool {\n\tif info == nil {\n\t\treturn false\n\t}\n\tfor _, broker := range info.BrokerAddrTable {\n\t\tif broker != nil && broker.BrokerAddrs[\"0\"] != \"\" {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc clusterTestResult(client *admin.Client, info *admin.ClusterInfo, config connectionConfig, proxies *proxyManager) map[string]any {","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rocketmq/connection.go#L181-L217","documentation":"Same wait loop as 933, but this variant fires when the context is cancelled with no prior poll error recorded — the broker never became available before the deadline. It wraps the context error alone.","triggerScenarios":"ctx cancelled or deadline exceeded on the first poll cycle before any poll returned an error; e.g. immediate cancellation or zero timeout.","commonSituations":"Passing an already-expired or pre-cancelled context; caller sets a very short deadline; cluster genuinely has no running master broker.","solutions":["Retry with a longer, non-expired context","Confirm a master broker is running and reachable before connecting","Check namesrv_addr correctness — polling an empty cluster will always time out"],"exampleFix":"// before\nctx, cancel := context.WithTimeout(ctx, 0) // already expired\n// after\nctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)","handlingStrategy":"retry","validationCode":"select {\ncase <-ctx.Done():\n    return errors.New(\"context already cancelled; pass a live context with deadline\")\ndefault:\n}","typeGuard":null,"tryCatchPattern":"client, err := buildClient(ctx, cfg)\nif errors.Is(err, context.DeadlineExceeded) {\n    ctx, cancel = context.WithTimeout(context.Background(), 2*timeout)\n    defer cancel()\n    client, err = buildClient(ctx, cfg)\n}","preventionTips":["Never pass pre-cancelled/zero-deadline contexts to connect","Verify at least one master broker is up before connecting","Use exponential backoff on this error family"],"tags":["timeout","broker-registration","context-cancelled"],"backgroundTag":"operation-timeout","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}