{"record":{"id":"8b57063791b8c69f","repo":"AlistGo/alist","slug":"receive-timeout","errorCode":null,"errorMessage":"receive timeout","messagePattern":"receive timeout","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"internal/message/http.go","lineNumber":75,"sourceCode":"\t\treturn \"\", errors.New(\"receive failed\")\n\t}\n}\n\nfunc (p *Http) WaitSend(message Message, d int) error {\n\tselect {\n\tcase p.ToSend <- message:\n\t\treturn nil\n\tcase <-time.After(time.Duration(d) * time.Second):\n\t\treturn errors.New(\"send timeout\")\n\t}\n}\n\nfunc (p *Http) WaitReceive(d int) (string, error) {\n\tselect {\n\tcase message := <-p.Received:\n\t\treturn message, nil\n\tcase <-time.After(time.Duration(d) * time.Second):\n\t\treturn \"\", errors.New(\"receive timeout\")\n\t}\n}\n\nvar HttpInstance = &Http{\n\tReceived: make(chan string),\n\tToSend:   make(chan Message),\n}\n","sourceCodeStart":57,"sourceCodeEnd":83,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/internal/message/http.go#L57-L83","documentation":"'receive timeout' is returned by (*Http).WaitReceive in internal/message/http.go when no message arrives on the Received channel within d seconds. It is the blocking counterpart of 'receive failed': the caller waited a bounded time and the time.After branch fired.","triggerScenarios":"WaitReceive(d) invoked when no producer writes to HttpInstance.Received during the window — e.g. no client has submitted a message via the HTTP receive endpoint, or messages are routed elsewhere.","commonSituations":"Legitimate idle periods with no inbound messages (treat as poll-empty); frontend disconnected; d shorter than the expected message production interval causing spurious timeouts in tests.","solutions":["Size d to the expected worst-case inter-message gap for your workload","Treat the timeout as a normal idle result (empty poll) rather than an error path in callers","Confirm the producer endpoint that feeds Received is being called with valid payloads","For tests, use generous timeouts or inject messages before waiting"],"exampleFix":"// before\nmsg, err := message.HttpInstance.WaitReceive(1)\nif err != nil { return err }\n\n// after\nmsg, err := message.HttpInstance.WaitReceive(30)\nif err != nil { msg = \"\" /* idle poll, not an error */ }","handlingStrategy":"fallback","validationCode":"// pick d based on expected inter-message interval\n// e.g. d = 2 * expectedGap","typeGuard":"func isReceiveTimeout(err error) bool {\n    return err != nil && err.Error() == \"receive timeout\"\n}","tryCatchPattern":"msg, err := message.HttpInstance.WaitReceive(d)\nif isReceiveTimeout(err) { msg = \"\" /* idle: normal */ }","preventionTips":["Treat timeout as idle, not failure","Use generous timeouts in tests","Verify the producer endpoint is exercised","Log timeouts at debug level"],"tags":["messaging","timeout","channel"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}