Skip to content

Commit bdbb1f2

Browse files
fix: move critical operations into try-block in get-modules
Moves `ensureDirectory()` and `validateModuleUrls()` into the try-block to ensure the finally block executes even if these operations fail early. Previously, if directory creation or URL validation failed immediately, the finally block was never reached, causing the output file to never be written and resulting in "ENOENT: no such file or directory" errors. This ensures `modules.stage.3.json` is always written, even with an empty modules array, allowing the pipeline to continue instead of failing completely.
1 parent 0265453 commit bdbb1f2

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

scripts/get-modules.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -525,22 +525,21 @@ async function processModules() {
525525
`Validating up to ${totalTargets} module URLs (concurrency=${cliOptions.urlConcurrency}, rate-limit=${rateLabel})`
526526
);
527527

528-
const validated = await validateModuleUrls({
529-
modules,
530-
limit: cliOptions.limit,
531-
urlConcurrency: cliOptions.urlConcurrency
532-
});
533-
534528
const validModules: ModuleEntry[] = [];
535529
const skippedModules: ReturnType<typeof createSkippedEntry>[] = [];
536530
let moduleCounter = 0;
537531
let consecutiveErrors = 0;
538532
const MAX_CONSECUTIVE_ERRORS = 10;
539533

540-
await ensureDirectory(MODULES_DIR);
541-
542534
// Use try-finally to ensure output is written even if errors occur
543535
try {
536+
await ensureDirectory(MODULES_DIR);
537+
538+
const validated = await validateModuleUrls({
539+
modules,
540+
limit: cliOptions.limit,
541+
urlConcurrency: cliOptions.urlConcurrency
542+
});
544543
for (const {
545544
module,
546545
ok,

0 commit comments

Comments
 (0)