Repository navigation
fix: prevent resume from skipping in-flight items - #2390
Simplereally wants to merge 1 commit into
Conversation
When Ctrl+C is pressed, the resume file now saves an index that is (currentIndex - Threads) to account for items that may be in-flight but not yet completed. This ensures that on resume, these items will be re-processed rather than skipped. The issue occurred because currentIndex was incremented at the start of processItem, before the actual HTTP request completed. When saving resume config during interrupt, up to Threads items could be in-flight. On resume, these items would be skipped because their index was already counted. The fix is conservative: it may re-process a few items that had already completed, but this is safe (httpx handles duplicates) while skipping items is not. Fixes projectdiscovery#2345
WalkthroughIntroduces a safety adjustment to the SaveResumeConfig function by subtracting the concurrent thread count from the current index before persistence, with a minimum floor of zero. This prevents skipping items still processing during resume operations, with new unit tests validating the calculation logic. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi @Mzack9999 @ehsandeep 👋 This PR fixes the resume.cfg skip issue (#2345) with a thread-safe approach. Ready for review whenever you have a moment. Thanks! 🙏 |
Summary
This PR fixes the resume functionality to prevent skipping items that were in-flight when Ctrl+C was pressed.
Problem
When httpx is interrupted with Ctrl+C, the resume file saves
currentIndexwhich includes items that were queued for processing but hadn't completed yet. On resume, these in-flight items would be skipped because their index was already counted, causing missing output.Root cause: The
currentIndexis incremented at the start ofprocessItem, beforer.process()spawns goroutines for the actual HTTP requests. When saving resume during interrupt, up toThreadsitems could be in-flight.Solution
When saving the resume config, subtract the thread count from
currentIndexto get a "safe" index:This is a conservative fix: it may re-process a few items that had already completed, but this is safe (httpx handles duplicates) while skipping items is not.
Testing
runner/resume_test.goChecklist
/claim #2345
Summary by CodeRabbit
Bug Fixes
Tests