Skip to content

fix(discover): an aborted run sends no batch; the watcher yields to Discover runs - #108

Merged
iLevyTate merged 1 commit into
mainfrom
fix/discover-strictmode-abort
Nov 10, 2026
Merged

iLevyTate merged 1 commit into
mainfrom
fix/discover-strictmode-abort

Conversation

@iLevyTate

Copy link
Copy Markdown
Owner

Found in a live dev run right after #106 and #107 merged.

Results never appeared ("0 ready", placeholders)

Timeline from the log:

  • 01:57:52: the user leaves Discover, and the run is cancelled and parked for resume.
  • 01:58:00: Discover remounts and the resume starts an 11-file run.
  • React StrictMode's simulated unmount aborts that run during its 10 ms start-up pause. The run still sends analysis:analyze-batch.
  • An aborted run's listeners ignore every operation-progress and analysis:file-complete event, so no result reached the list. Redux progress, which comes from ipcMiddleware, still showed "Analyzing 4 of 11".
  • 02:03:01: Analysis lock timeout with lastProgressAt still at the 01:58:00 start. The run resets, cancels the batch after 6 files, and turns the image in progress into a filename-only "Limited analysis".

Fix: runBatchPathWhenFree returns superseded before any attempt when the run is aborted or superseded, and the run skips the completion notice. Its existing finally releases the lock and starts the files the remount queued.

The watcher halved Discover runs

On launch the watcher restored and queued about 879 smart-folder files that this app's history did not know, likely a library sorted by another app. It analyzed them file by file, alternating with the user's Discover batch. It now holds its queue while any user-started analysis is running (hasUserAnalysisInFlight), rechecks every 5 s, and resumes on its own. The hold timer is cleared on stop.

Verified

  • useAnalysis.test.js: an unmount during the start-up pause sends no batch, and under StrictMode a resumed run sends one batch whose results reach the list. Both fail on the previous code. The new tests import React and the hook at module scope, because a later test calls jest.resetModules().
  • SmartFolderWatcher.userAnalysisDefer.test.js: a held queue analyzes nothing during the run and resumes after it.
  • 21 related suites (343 tests) pass. Lint and typecheck:js are clean.

…iscover runs

Live dev run: Discover remounted, the resume started an 11-file run, and
StrictMode's simulated unmount aborted it during its 10 ms start-up pause.
The run still sent its batch, and an aborted run's listeners ignore every
progress and file-complete event, so the list stayed at '0 ready' with
placeholders until the 5-minute inactivity lock cancelled the batch (the
image in progress became a filename-only 'Limited analysis'). The wait helper
now refuses to send for an aborted or superseded run, and the run returns
without a completion notice; its finally starts the files the remount queued.

The smart-folder watcher holds its queue while any user-started analysis is in
flight (userAnalysisInFlight) and resumes on its own afterwards, so a startup
catch-up of hundreds of smart-folder files no longer halves a Discover run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant