{"record":{"id":"ed2ddf73b209a059","repo":"projectdiscovery/nuclei","slug":"max-sleep-count","errorCode":null,"errorMessage":"max sleep count","messagePattern":"max sleep count","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/protocols/headless/engine/instance.go","lineNumber":70,"sourceCode":"\treturn i.engine.Close()\n}\n\n// SetInteractsh client\nfunc (i *Instance) SetInteractsh(interactsh *interactsh.Client) {\n\ti.interactsh = interactsh\n}\n\n// maxBackoffSleeper is a backoff sleeper respecting max backoff values\nfunc maxBackoffSleeper(max int) utils.Sleeper {\n\tcount := 0\n\tbackoffSleeper := utils.BackoffSleeper(100*time.Millisecond, 500*time.Millisecond, nil)\n\n\treturn func(ctx context.Context) error {\n\t\tif ctx.Err() != nil {\n\t\t\treturn ctx.Err()\n\t\t}\n\t\tif count == max {\n\t\t\treturn errors.New(\"max sleep count\")\n\t\t}\n\t\tcount++\n\t\treturn backoffSleeper(ctx)\n\t}\n}\n","sourceCodeStart":52,"sourceCodeEnd":76,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/protocols/headless/engine/instance.go#L52-L76","documentation":"instance.go installs maxBackoffSleeper(10) as the go-rod browser sleeper; every internal rod operation that waits (connecting to the browser, evaluating CDP calls) goes through it. After 10 sleeps (exponential 100ms-500ms, i.e. a few seconds total) the sleeper returns 'max sleep count', aborting whatever browser operation was pending. It almost always means Chrome started but its DevTools endpoint never became usable.","triggerScenarios":"Chrome process launches but stalls: starved CI containers, tiny /dev/shm, low file-descriptor limits, or a stale/zombie chrome holding the debug port. Any rod call that keeps failing fast burns one of the 10 backoff slots.","commonSituations":"Docker with default 64MB /dev/shm running headless Chrome; low-memory GitHub Actions runners; leftover chrome processes from a previous crashed run; concurrent nuclei instances fighting for CPU.","solutions":["Kill stale chrome/chromium processes and retry the scan","Give the container more shared memory and CPU (docker run --shm-size=1g, raise memory limits)","Run fewer concurrent headless templates (-concurrency-limit, -headless-concurrency) so Chrome gets resources","Use -system-chrome with a known-good installed browser as an alternative to the downloaded Chromium"],"exampleFix":"# before\ndocker run --rm -it nuclei:v3 -tags headless -u file.txt\n# after\ndocker run --rm -it --shm-size=1g --memory=2g nuclei:v3 -tags headless -u file.txt","handlingStrategy":"retry","validationCode":"pkill -f 'chrome.*remote-debugging-port' 2>/dev/null || true  # clear zombie browsers before a headless run","typeGuard":null,"tryCatchPattern":"var berr *rod.ErrBrowser // or string-match on 'max sleep count'\nif err != nil && strings.Contains(err.Error(), \"max sleep count\") {\n    // browser stall: back off, kill stale chrome, retry once\n    time.Sleep(5 * time.Second)\n    _ = exec.Command(\"pkill\", \"-f\", \"remote-debugging-port\").Run()\n    return retryScan()\n}","preventionTips":["Run headless containers with --shm-size=1g and adequate memory/CPU limits","Cap headless concurrency so Chrome instances are not starved","Clean up chrome processes after crashed runs; reaping zombies prevents port conflicts"],"tags":["headless","browser","retry","resources","docker"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}