Comfy-Org/ComfyUI · warning · ScanInProgressError
Cannot mark missing assets while scan is running
Error message
Cannot mark missing assets while scan is running
What it means
ScanInProgressError raised by the seeder's mark-missing routine when its state machine is not IDLE at call time. The routine needs exclusive access to flip state to RUNNING and sweep for references whose files disappeared, so it refuses to start concurrently with a scan. Note the routine sets RUNNING itself and later restores IDLE; dependencies being unavailable skips the work but still returns 0.
Source
Thrown at app/assets/seeder.py:404
This is a non-destructive soft-delete operation. Assets and their
metadata are preserved, but references are flagged as missing.
They can be restored if the file reappears in a future scan.
This operation is decoupled from scanning to prevent partial scans
from accidentally marking assets belonging to other roots.
Should be called explicitly when cleanup is desired, typically after
a full scan of all roots or during maintenance.
Returns:
Number of references marked as missing
Raises:
ScanInProgressError: If a scan is currently running
"""
with self._lock:
if self._state != State.IDLE:
raise ScanInProgressError(
"Cannot mark missing assets while scan is running"
)
self._state = State.RUNNING
try:
if not dependencies_available():
logging.warning(
"Database dependencies not available, skipping mark missing"
)
return 0
all_prefixes = get_all_known_prefixes()
marked = mark_missing_outside_prefixes_safely(all_prefixes)
if marked > 0:
logging.info("Marked %d references as missing", marked)
return marked
finally:
with self._lock:View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Wait for the current scan to finish (poll state until IDLE) before calling mark-missing.
- Disable/gate the mark-missing action in the UI whenever a scan is active.
- If the state is stuck at RUNNING after a crash, restart the seeder/process to reset the state machine.
- Catch ScanInProgressError and surface a 'scan in progress, try again later' message instead of retrying immediately.
Example fix
// before
seeder.mark_missing()
// after
from app.assets.seeder import ScanInProgressError
try:
seeder.mark_missing()
except ScanInProgressError:
return {"status": "busy", "detail": "scan running; retry after it completes"} Defensive patterns
Strategy: retry
Validate before calling
def can_mark_missing(seeder) -> bool:
# state must be IDLE; expose or read the seeder's state if available
return seeder._state.name == "IDLE" if hasattr(seeder, "_state") else True Try / catch
from app.assets.seeder import ScanInProgressError
try:
removed = seeder.mark_missing()
except ScanInProgressError:
# schedule a retry after the scan completes; do not spin
return {"status": "busy", "retry_after": "scan completes"} Prevention
- Gate mark-missing UI actions on the seeder reporting IDLE.
- Schedule maintenance windows that cannot overlap scan windows.
- Treat a stuck RUNNING state after a crash as a bug — restart to reset the state machine.
When it happens
Trigger: Invoking mark_missing (or the maintenance endpoint wrapping it) while a library scan is in progress — including when the previous mark-missing run has not yet returned to IDLE.
Common situations: Scheduling maintenance (cron/CI) without accounting for long library scans on huge roots; a crashed scan leaving the state stuck at RUNNING; UI buttons for 'clean up missing files' enabled while a scan badge is active.
Related errors
- Could not acquire lock on database '{db_path}'. Another Comf
- eglMakeCurrent() failed (EGL error: 0x{err:04X})
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/badea38a9a779585.
Report an issue: GitHub.