{"record":{"id":"e949c0a0d1d1c268","repo":"dutchcoders/transfer.sh","slug":"clamav-scan-timeout","errorCode":null,"errorMessage":"clamav scan timeout","messagePattern":"clamav scan timeout","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/clamav.go","lineNumber":100,"sourceCode":"\terrCh := make(chan error)\n\tgo func(responseCh chan chan *clamd.ScanResult, errCh chan error) {\n\t\tresponse, err := c.ScanFile(path)\n\t\tif err != nil {\n\t\t\terrCh <- err\n\t\t\treturn\n\t\t}\n\n\t\tresponseCh <- response\n\t}(responseCh, errCh)\n\n\tselect {\n\tcase err := <-errCh:\n\t\treturn \"\", err\n\tcase response := <-responseCh:\n\t\tst := <-response\n\t\treturn st.Status, nil\n\tcase <-time.After(time.Second * 60):\n\t\treturn \"\", errors.New(\"clamav scan timeout\")\n\t}\n}\n","sourceCodeStart":82,"sourceCodeEnd":103,"githubUrl":"https://github.com/dutchcoders/transfer.sh/blob/c37bfd95797fd6da8a6da53fc13d191994b3f687/server/clamav.go#L82-L103","documentation":"performScan wraps the ClamAV clamd INSTREAM virus scan in a 60-second timeout implemented via select/time.After. If the clamd daemon neither returns a response nor an error within 60 seconds, the scan is abandoned and this error is returned to the upload handlers (scan/post/put). It indicates the antivirus backend is unresponsive or the file scan is taking too long.","triggerScenarios":"Uploading a file with --av scan enabled (VIRUSTOTAL/clamav passthrough) when clamd is overloaded, scanning a very large file over a slow clamd socket, or clamd is hung/down so the TCP connection stalls until the 60s timer fires.","commonSituations":"clamd daemon under heavy load or in signature-reload, clamd running on a remote host with network latency, scanning multi-hundred-MB uploads, or a misconfigured clamd address causing silent connection stalls.","solutions":["Check the clamd daemon is running and responsive (clamd scan / PING on the configured host:port) and restart it if hung.","Reduce upload file size limits or exclude very large files from AV scanning.","Increase capacity: run clamd closer to the server (unix socket / same host) or scale concurrent clamd instances.","Patch the 60s constant in server/clamav.go to a configurable, larger timeout for large-file workloads."],"exampleFix":"// before\ncase <-time.After(time.Second * 60):\n\treturn \"\", errors.New(\"clamav scan timeout\")\n// after\ntimeout := s.avScanTimeout // configurable, e.g. 5 * time.Minute\ncase <-time.After(timeout):\n\treturn \"\", fmt.Errorf(\"clamav scan timeout after %s\", timeout)","handlingStrategy":"retry","validationCode":"// before uploading, verify clamd is reachable\ntimeout 5 bash -c 'cat < /dev/null > /dev/tcp/clamav-host/3310' || echo \"clamd unreachable\"","typeGuard":null,"tryCatchPattern":"if _, err := upload(f); err != nil {\n\tif strings.Contains(err.Error(), \"clamav scan timeout\") {\n\t\t// back off and retry once, or skip AV scanning for this file\n\t\ttime.Sleep(30 * time.Second)\n\t\treturn upload(f)\n\t}\n\treturn err\n}","preventionTips":["Monitor clamd health (PING command) and alert on hangs.","Run clamd on a fast local unix socket rather than a remote host.","Cap upload sizes or configure a generous, explicit scan timeout."],"tags":["timeout","clamav","antivirus","network"],"backgroundTag":"operation-timeout","analyzedSha":"c37bfd95797fd6da8a6da53fc13d191994b3f687","analyzedAt":"2026-09-05T10:21:07.548Z","contentChangedAt":"2026-09-05T10:21:07.548Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}