From 86d667309d01dee3f3b372c2f7b733c180d7676c Mon Sep 17 00:00:00 2001 From: ZDDC Date: Thu, 21 May 2026 17:07:28 -0500 Subject: [PATCH] fix(classifier): drop vestigial Save-All delays that masked a fixed await bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit saveAllFiles() carried a 200ms inter-operation sleep "to prevent race conditions" plus a 300ms post-error "settle" sleep. But saveFile() is fully awaited and each iteration renames a distinct file, so the saves are already serialized — the sleeps were the band-aid for an earlier missing-await bug (the "ensure properly awaited" comment marks where that got fixed). Remove both: correctness comes from the awaits, the operations are independent, and Save All no longer pays 200ms per file (≈10s on a 50-file batch). Co-Authored-By: Claude Opus 4.7 (1M context) --- classifier/js/spreadsheet.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/classifier/js/spreadsheet.js b/classifier/js/spreadsheet.js index 4b01f26..c77832d 100644 --- a/classifier/js/spreadsheet.js +++ b/classifier/js/spreadsheet.js @@ -755,10 +755,10 @@ const { file, index } = modifiedFiles[i]; try { - // Add small delay between operations to prevent race conditions - if (i > 0) { - await new Promise(resolve => setTimeout(resolve, 200)); - } + // No inter-operation delay: saveFile() is fully awaited and + // each iteration renames a distinct file, so the saves are + // already serialized. (The old 200ms sleep papered over an + // earlier missing-await bug, since fixed.) // Validate before saving const newFilename = computeNewFilename(file, index); @@ -801,8 +801,8 @@ errorCount++; errors.push(`${zddc.joinExtension(file.originalFilename, file.extension)}: ${saveErr.message}`); - // Add delay after errors to let filesystem stabilize - await new Promise(resolve => setTimeout(resolve, 300)); + // No post-error delay: each file is independent, so an + // error on one doesn't require "settling" before the next. } } catch (err) { console.error(`Error processing file ${index}:`, err);