{"record":{"id":"b9f0ded06a3d1c16","repo":"wavetermdev/waveterm","slug":"invalid-rwnd-size-d","errorCode":null,"errorMessage":"invalid rwnd size: %d","messagePattern":"invalid rwnd size: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/jobmanager/jobmanager.go","lineNumber":171,"sourceCode":"\t}\n}\n\nfunc (jm *JobManager) GetJobAuthInfo() (string, string) {\n\tjm.lock.Lock()\n\tdefer jm.lock.Unlock()\n\treturn jm.JobId, jm.JobAuthToken\n}\n\nfunc (jm *JobManager) IsJobStarted() bool {\n\tjm.lock.Lock()\n\tdefer jm.lock.Unlock()\n\treturn jm.Cmd != nil\n}\n\nfunc (jm *JobManager) connectToStreamHelper_withlock(mainServerConn *MainServerConn, streamMeta wshrpc.StreamMeta, seq int64) (int64, error) {\n\trwndSize := int(streamMeta.RWnd)\n\tif rwndSize < 0 {\n\t\treturn 0, fmt.Errorf(\"invalid rwnd size: %d\", rwndSize)\n\t}\n\n\tif jm.connectedStreamClient != nil {\n\t\tlog.Printf(\"connectToStreamHelper: disconnecting existing client\\n\")\n\t\toldStreamId := jm.StreamManager.GetStreamId()\n\t\tjm.StreamManager.ClientDisconnected()\n\t\tif oldStreamId != \"\" {\n\t\t\tmainServerConn.WshRpc.StreamBroker.DetachStreamWriter(oldStreamId)\n\t\t\tlog.Printf(\"connectToStreamHelper: detached old stream id=%s\\n\", oldStreamId)\n\t\t}\n\t\tjm.connectedStreamClient = nil\n\t}\n\tdataSender := &routedDataSender{\n\t\twshRpc: mainServerConn.WshRpc,\n\t\troute:  streamMeta.ReaderRouteId,\n\t}\n\tserverSeq, err := jm.StreamManager.ClientConnected(\n\t\tstreamMeta.Id,","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/jobmanager/jobmanager.go#L153-L189","documentation":"connectToStreamHelper_withlock reads streamMeta.RWnd (receive window size) as an int and rejects negative values before connecting the stream client. The error indicates the client sent a negative RWnd, which is meaningless for flow control.","triggerScenarios":"A StartJob or PrepareConnect request whose StreamMeta.RWnd is negative (e.g. -1 used as a 'default' sentinel by a buggy client, or integer underflow when computing the window size).","commonSituations":"Client code initializing RWnd to -1 or 0 minus a value by mistake; version mismatch where one side encodes RWnd differently; manual JSON construction of StreamMeta with a wrong field.","solutions":["Fix the caller to send a non-negative RWnd (use the protocol's default size constant instead of -1)","Validate RWnd on the client before building StreamMeta and clamp to a sensible minimum (e.g. 4096)","Omit StreamMeta entirely if the caller does not intend to stream, rather than sending a bogus RWnd","Check for signed/unsigned conversion bugs (int32 -> int64) that produce negatives"],"exampleFix":"// before\nmeta := wshrpc.StreamMeta{Id: id, RWnd: -1}\n// after\nconst DefaultRWnd = 8192\nrwnd := DefaultRWnd\nmeta := wshrpc.StreamMeta{Id: id, RWnd: rwnd}","handlingStrategy":"validation","validationCode":"if streamMeta.RWnd < 0 {\n    return fmt.Errorf(\"RWnd must be >= 0, got %d; use the default size instead\", streamMeta.RWnd)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never use -1 as a sentinel for RWnd; use 0 or a documented default","Check signed/unsigned conversions when computing window sizes","Validate StreamMeta fields on the client before sending","Pin client and server to compatible versions"],"tags":["streaming","validation","flow-control"],"backgroundTag":"invalid-parameter","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}