{"record":{"id":"37cf077d27912660","repo":"tirth8205/code-review-graph","slug":"watch-update-failed","errorCode":null,"errorMessage":"watch update failed","messagePattern":"watch update failed","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"code_review_graph/incremental.py","lineNumber":2284,"sourceCode":"                )\n                if not changed_files:\n                    return\n                result = incremental_update(\n                    repo_root,\n                    store,\n                    changed_files=changed_files,\n                    reconcile_stale=False,\n                )\n                _raise_watch_update_errors(result, \"incremental update\")\n                if result[\"files_updated\"] > 0 and on_files_updated is not None:\n                    postprocess_result = on_files_updated(store)\n                    _raise_watch_postprocess_warnings(postprocess_result)\n            except BaseException as exc:\n                self.failure = exc\n\n        def raise_if_failed(self) -> None:\n            if self.failure is not None:\n                raise RuntimeError(\"watch update failed\") from self.failure\n\n    processor = WatchBatchProcessor()\n    debouncer = EventDebouncer(_DEBOUNCE_SECONDS, processor.process)\n\n    class GraphUpdateHandler(FileSystemEventHandler):\n        def dispatch(self, event: FileSystemEvent) -> None:\n            if event.event_type not in {\"created\", \"modified\", \"deleted\", \"moved\"}:\n                return\n            if event.is_directory and event.event_type == \"modified\":\n                return\n            debouncer.handle_event(event)\n\n        def start(self) -> None:\n            debouncer.start()\n\n        def stop(self) -> None:\n            debouncer.stop()\n            debouncer.join()","sourceCodeStart":2266,"sourceCodeEnd":2302,"githubUrl":"https://github.com/tirth8205/code-review-graph/blob/b58668751ab0c7670c078cf7cbd4d1f5b8e54f81/code_review_graph/incremental.py#L2266-L2302","documentation":"Raised by WatchBatchProcessor.raise_if_failed after a filesystem-watch batch update raised an exception. The watcher catches the original failure (stored in self.failure) and re-raises it wrapped as RuntimeError('watch update failed') so the graph never silently goes stale.","triggerScenarios":"Calling watch() on an IncrementalUpdater (or via the daemon 'start' command) when a debounced batch of filesystem events triggers a graph update that throws — e.g. a corrupt index DB, unparsable file, or IO error during postprocessing.","commonSituations":"Long-running watch daemon where a transient disk/SQLite error occurs mid-update; concurrent processes locking the graph database; graph state corrupted by a crashed prior run.","solutions":["Inspect the __cause__ of the RuntimeError — the original exception identifies the real failure (e.g. sqlite3.OperationalError: database is locked).","If it is a lock contention issue, ensure only one watcher/daemon instance runs per repo and stop conflicting processes.","Delete the stale .code-review-graph state directory and let the watcher rebuild the graph from scratch.","If the error persists, run a full non-incremental reindex to regenerate consistent graph state before restarting the watch."],"exampleFix":"// before\nupdater.watch(repo_root)\n// after\ntry:\n    updater.watch(repo_root)\nexcept RuntimeError as exc:\n    log.error(\"watch failed: %s\", exc.__cause__)\n    rebuild_graph_state(repo_root)  # e.g. remove .code-review-graph and reindex\n    updater.watch(repo_root)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    updater.watch(repo_root)\nexcept RuntimeError as exc:\n    if \"watch update failed\" in str(exc):\n        logger.error(\"watch failed: %s\", exc.__cause__)\n        # let the daemon restart the watcher; optionally rebuild graph state","preventionTips":["Run only one watcher per repository to avoid DB lock contention.","Wrap watch() in supervisor restart logic — the error is designed to be restartable.","Keep the .code-review-graph state on reliable storage; rebuild it after crashes."],"tags":["watcher","filesystem","graph-update","daemon"],"backgroundTag":"background-watcher-crash-loop","analyzedSha":"b58668751ab0c7670c078cf7cbd4d1f5b8e54f81","analyzedAt":"2026-08-28T13:19:08.966Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}