fix(scripts): correct premature return in markStale and add --debug flag to auto-close-duplicates#65344
Open
FrancescoCastaldi wants to merge 2 commits into
Conversation
In markStale(), when an issue's updated_at is newer than the cutoff the original code used `return labeled` which exits the entire function, skipping all remaining pages. Since issues are sorted by updated asc, a `break` is correct: it exits the inner for-loop over issues on the current page and lets the outer page-loop also break naturally (because subsequent pages will have even newer issues). This ensures all stale issues across pages are consistently processed.
…logs Refactor logging to use a dedicated log function and update debug messages.All [DEBUG] console.log calls were printed unconditionally, flooding CI output on every run. This refactor introduces a structured log() helper and a --debug CLI flag: DEBUG-level messages are suppressed unless the flag is passed, while INFO/SUCCESS/ERROR always print. Also adds argv to the global process declaration so TypeScript no longer needs a cast to access process.argv.
Kachhawa96
approved these changes
Jun 4, 2026
This was referenced Jun 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a logic bug in
scripts/sweep.tsand improves the logging ergonomics ofscripts/auto-close-duplicates.ts.scripts/sweep.ts— fix prematurereturninmarkStale()Bug: When iterating over paginated issues (sorted by
updated_at asc), the original code usedreturn labeledas soon as it encountered an issue newer than the stale cutoff. This exits the entire function, meaning issues on subsequent pages are never evaluated even if they were correctly stale.Fix: Replace
return labeledwithbreak. Since issues are sorted ascending byupdated_at, abreakexits the inner issue-loop for the current page; the outer page-loop then naturally terminates on the next iteration because all further pages will also be newer than the cutoff. This ensures every page is processed correctly.scripts/auto-close-duplicates.ts— add--debugflag to control verbosityProblem: All
[DEBUG]log lines were printed unconditionally on every CI run, producing hundreds of noisy lines even in normal operation.Fix: Introduces a small
log(level, message)helper and a--debugCLI flag:DEBUGmessages are suppressed unless--debugis passedINFO,SUCCESS, andERRORmessages always printargv: string[]to thedeclare globalblock so TypeScript resolvesprocess.argvwithout a castUsage: