Skip to content

Fix --sort crashing when a file is deleted during the run to close #819 - #836

Merged
mathiasrw merged 3 commits into
mainfrom
fix/819
Oct 23, 2026
Merged

mathiasrw merged 3 commits into
mainfrom
fix/819

Conversation

@mathiasrw

@mathiasrw mathiasrw commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Closes #819

Stacked on #835.

Change

With --sort modified, created or size, each file is looked at with fs.statSync. A file that was deleted between the glob and the sort crashed the run with a stack trace and exit code 1.

Now a file that can not be looked at in the sort is sorted last, and the run goes on. When the file is then opened, it is told about as File not found, like without --sort (exit code 2). The check for the time a file was made skips it too.

Tests

test/fix/819.test.js is new. It makes the sort see a file as deleted, for each of the three sorts, and fails without the fix. yarn test-ci passes.

From the review of 23 October.

After the review of 24 October

  • Only a file that is really gone (ENOENT) is sorted last, and told about as File not found when it is opened. Any other error, like a folder that turns unreadable, is now an error with its own reason, and the file is left out, so the reason is not hidden as not found.
  • The test now deletes the file while it is sorted, and checks the File not found and the exit code 2. A new test checks another error.
  • With --halt sorting the file last changes nothing: the files are all started at once, and the first error stops the run. Sorting it last helps the runs without --halt.

Follow-up

  • The warning for --sort created is now "This file system does not know when files were created. Sorting via modified time instead."
  • test/fix/819.test.js has more edge cases: the files are made so each sort gives an order that is not the ascii order, and the files to delete would sort first. Two deleted files, --sort-reverse, --halt, and the other error with and without --halt. All 8 tests fail without the fix.
  • Good to know: the check for missing files runs right after the sort and before any file is opened, so a deleted file is told about first, where ever the sort put it.

@mathiasrw
mathiasrw marked this pull request as draft October 23, 2026 13:05
@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 13:22
@mathiasrw
mathiasrw added this pull request to stack #841 October 23, 2026 13:56
@mathiasrw
mathiasrw marked this pull request as draft October 23, 2026 15:28
@mathiasrw mathiasrw changed the title Sort a file that is gone before the sort last, and do not crash to close #819 Fix --sort crashing when a file is deleted during the run to close #819 Oct 23, 2026
@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 15:37
@mathiasrw
mathiasrw removed this pull request from stack #841 October 23, 2026 15:57
@mathiasrw
mathiasrw added this pull request to stack #849 October 23, 2026 16:12
@mathiasrw
mathiasrw removed this pull request from stack #849 October 23, 2026 16:12
@mathiasrw
mathiasrw added this pull request to stack #850 October 23, 2026 16:17
@mathiasrw
mathiasrw removed this pull request from stack #850 October 23, 2026 16:47
@mathiasrw
mathiasrw added this pull request to stack #853 October 23, 2026 16:51
@mathiasrw
mathiasrw force-pushed the fix/819 branch 3 times, most recently from ed35da3 to 2916ff8 Compare October 23, 2026 17:01
Base automatically changed from fix/818 to main October 23, 2026 17:02
@mathiasrw
mathiasrw merged commit 969c6d0 into main Oct 23, 2026
6 of 7 checks passed
@mathiasrw
mathiasrw deleted the fix/819 branch October 23, 2026 17:12
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.

Fix --sort crashing when a file is gone before the sort

1 participant