You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix files left only as .backup when a run stops #813
When one file fails in the middle of a run, the CLI ends the process while other files are halfway through being written. A file is written by renaming it to a .backup, writing the new content, and then removing the backup. A file that is cut off between the first two steps is left only as .backup, and the original is gone.
foriin$(seq -w 0 199);doprintf foo > b$i.txt;done
rexreplace foo "if (filename === 'b050.txt') throw new Error('boom'); 'bar'""b*.txt" --js
ls b*.txt | grep -vc backup # less than 200
It happens with and without --halt, for a panic and for a write error.
The cause: the workers run with Promise.all, which rejects at the first error while the other workers are still in the middle of a file, and then the CLI calls process.exit(3).
Change
Let the engine wait for all workers with Promise.allSettled, and then throw the first error. Then the CLI only ends the process when every file in work is done. With --halt no new file is started (#789), but a file in work is always finished.
Tests
A test that checks the files themselves after the run: no file is missing, and there is no .backup.
Good to know
#809 and #811 say this is handled, but their tests only check the exit code. Found in the review of 23 October.
Activity
Await async work before exiting to close #789 and #813 (#811)