{"record":{"id":"66df9f7246bcbedb","repo":"wavetermdev/waveterm","slug":"stream-broker-not-available-66df9f","errorCode":null,"errorMessage":"stream broker not available","messagePattern":"stream broker not available","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/remote/fileshare/wshfs/wshfs.go","lineNumber":54,"sourceCode":"\tconn, err := connparse.ParseURIAndReplaceCurrentHost(ctx, path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing connection %s: %w\", path, err)\n\t}\n\treturn conn, nil\n}\n\nfunc Read(ctx context.Context, data wshrpc.FileData) (*wshrpc.FileData, error) {\n\tif data.Info == nil {\n\t\treturn nil, fmt.Errorf(\"file info is required\")\n\t}\n\tlog.Printf(\"Read: %v\", data.Info.Path)\n\tconn, err := parseConnection(ctx, data.Info.Path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbroker := RpcClient.StreamBroker\n\tif broker == nil {\n\t\treturn nil, fmt.Errorf(\"stream broker not available\")\n\t}\n\tif RpcClientRouteId == \"\" {\n\t\treturn nil, fmt.Errorf(\"no route id available\")\n\t}\n\treaderRouteId := RpcClientRouteId\n\twriterRouteId := wshutil.MakeConnectionRouteId(conn.Host)\n\treader, streamMeta := broker.CreateStreamReader(readerRouteId, writerRouteId, 256*1024)\n\tdefer reader.Close()\n\tgo func() {\n\t\t<-ctx.Done()\n\t\treader.Close()\n\t}()\n\tbyteRange := \"\"\n\tif data.At != nil && data.At.Size > 0 {\n\t\tbyteRange = fmt.Sprintf(\"%d-%d\", data.At.Offset, data.At.Offset+int64(data.At.Size)-1)\n\t}\n\tremoteData := wshrpc.CommandRemoteFileStreamData{\n\t\tPath:       conn.Path,","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/remote/fileshare/wshfs/wshfs.go#L36-L72","documentation":"Read streams file contents through RpcClient.StreamBroker; if the global RpcClient was initialized but its StreamBroker is nil, the streaming machinery does not exist and Read aborts with this error. The broker is normally set up during RPC client initialization, so a nil broker indicates incomplete initialization.","triggerScenarios":"Calling wshfs.Read before (or without) proper WshRpc initialization where StreamBroker was never assigned; using a plain WshRpc instance that only supports request/response RPCs.","commonSituations":"Embedding wshfs in a custom binary that constructs WshRpc manually without installing a stream broker; initialization order bug where Read runs before setup completes; a version change altered broker setup.","solutions":["Ensure RpcClient is initialized with a StreamBroker (wshutil.NewWshRpc / broker setup) before calling Read","Verify the code path that installs StreamBroker actually runs in your binary (main-server or wshcmd-connserver)","Check initialization order — Read must not be called before RPC setup finishes"],"exampleFix":"// before\nwshfs.RpcClient = wshutil.NewWshRpc() // StreamBroker never set\n// after\nrpc := wshutil.NewWshRpc()\nrpc.StreamBroker = wshutil.NewWshStreamBroker() // install broker before use\nwshfs.RpcClient = rpc","handlingStrategy":"fallback","validationCode":"if wshfs.RpcClient == nil || wshfs.RpcClient.StreamBroker == nil {\n    return errors.New(\"wshfs RPC client or stream broker not initialized\")\n}","typeGuard":"func brokerReady() bool {\n    return wshfs.RpcClient != nil && wshfs.RpcClient.StreamBroker != nil\n}","tryCatchPattern":"out, err := wshfs.Read(ctx, data)\nif err != nil {\n    if strings.Contains(err.Error(), \"stream broker not available\") {\n        return fmt.Errorf(\"streaming unsupported in this build/init: %w\", err) // fallback: use non-streaming RPC\n    }\n    return err\n}","preventionTips":["Initialize StreamBroker at the same place RpcClient is assigned","Add a startup health check asserting broker readiness before serving requests","Sequence initialization: broker first, then accept file commands","Document broker requirement wherever wshfs is embedded"],"tags":["go","initialization","streaming"],"backgroundTag":"stream-broker-unavailable","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}