{"record":{"id":"e52146f97336d721","repo":"crowdsecurity/crowdsec","slug":"could-not-remove-all-inotify-watches-w","errorCode":null,"errorMessage":"could not remove all inotify watches: %w","messagePattern":"could not remove all inotify watches: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/file/run.go","lineNumber":183,"sourceCode":"\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tfor _, file := range files {\n\t\t\t\t\t_ = s.checkAndTailFile(file, logger, out, t)\n\t\t\t\t}\n\t\t\t}\n\n\t\tcase err, ok := <-s.watcher.Errors:\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\tlogger.Errorf(\"Error while monitoring folder: %s\", err)\n\n\t\tcase <-t.Dying():\n\t\t\terr := s.watcher.Close()\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"could not remove all inotify watches: %w\", err)\n\t\t\t}\n\n\t\t\treturn nil\n\t\t}\n\t}\n}\n\nfunc (s *Source) setupTailForFile(file string, out chan pipeline.Event, seekEnd bool, t *tomb.Tomb) error {\n\tlogger := s.logger.WithField(\"file\", file)\n\n\tif s.isExcluded(file) {\n\t\treturn nil\n\t}\n\n\t// Check if we're already tailing\n\ts.tailMapMutex.RLock()\n\n\tif s.tails[file] {","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/file/run.go#L165-L201","documentation":"monitorNewFiles, on shutdown (tomb dying), closes the inotify watcher; if watcher.Close fails (watches cannot be removed) the streaming loop returns this error instead of exiting cleanly. Rare OS-level cleanup failure during acquisition stop.","triggerScenarios":"Thrown at pkg/acquisition/modules/file/run.go:183 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Usually transient; restart crowdsec","Check system logs for inotify/kernel issues if it recurs"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}