Skip to content

drain sources - #1799

Merged
dogancanbakir merged 1 commit into
devfrom
drain-sources
Jul 1, 2026
Merged

dogancanbakir merged 1 commit into
devfrom
drain-sources

Conversation

@Mzack9999

@Mzack9999 Mzack9999 commented Jun 25, 2026 •

Copy link
Copy Markdown
Member

drain source channels on cancel so source goroutines exit instead of leaking on a blocked send

Closes #1798

Summary by CodeRabbit

  • Bug Fixes
    • Improved cancellation handling during subdomain enumeration so sources are fully drained even when the operation is stopped early.
    • Reduced the risk of blocked background work and goroutine leaks when results back up or the consumer stops reading.
    • Added a test to verify source goroutines exit cleanly under cancellation and backpressure.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e81fd3ec-c86c-4125-a4af-04fc81b3fc75

📥 Commits

Reviewing files that changed from the base of the PR and between 292032e and d045876.

📒 Files selected for processing (2)
  • pkg/passive/drain_test.go
  • pkg/passive/passive.go

Walkthrough

The passive enumerator now drains each source’s result channel after cancellation instead of returning immediately. A new test simulates a blocked source under timeout-driven backpressure and checks that its goroutine exits.

Changes

Passive enumeration cancel drain

Layer / File(s) Summary
Drain on cancel
pkg/passive/passive.go
The per-source forwarding loop changes its ctx.Done() branch to keep reading sourceResults until the source channel closes.
Regression test with blocked source
pkg/passive/drain_test.go
A mock source sends bare channel results from a goroutine, and the test verifies enumeration cancellation does not leave that goroutine running.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A bunny saw the timeout light,
Then drained the stream and made it right.
No hop got stuck in channel snow,
The source ran free, the thumps all glow.
🐇🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the main change: draining sources during cancellation.
Linked Issues check ✅ Passed The code and test address #1798 by draining source channels on cancellation so blocked sources can exit cleanly.
Out of Scope Changes check ✅ Passed The changes stay focused on cancellation draining behavior and its regression test, with no obvious unrelated additions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch drain-sources

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dogancanbakir
dogancanbakir merged commit 44bf9d8 into dev Jul 1, 2026
9 checks passed
@dogancanbakir
dogancanbakir deleted the drain-sources branch July 1, 2026 08:56
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
subfinder 2.15.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## What's Changed

### 🎉 New Features
* Added shodanct passive source by @dogancanbakir in projectdiscovery/subfinder#1796
* Added Option `-vR`, `-virustotal-res` for VirusTotal source by @Bundy01 in projectdiscovery/subfinder#1719
* Added machine-readable source listing with `-ls -oJ` by @Gerijacki in projectdiscovery/subfinder#1812

### 🐞 Bug Fixes
* Fixed source leaks by @Mzack9999 in projectdiscovery/subfinder#1801
* Fixed drain source channels on cancel so source goroutines exit instead of leaking on a blocked send by @Mzack9999 in projectdiscovery/subfinder#1799
* Fixed crtsh's query by dropping unused certificate metadata from SQL query by @ChrisJr404 in projectdiscovery/subfinder#1787
* Fixed VirusTotal source by capping pagination and providing clearer 429 message by @ChrisJr404 in projectdiscovery/subfinder#1788
* Fixed Anubis source by switching subdomain API to anubisdb.com by @jatinder14 in projectdiscovery/subfinder#1815

### Other Changes
* Fixed lint issues by @dogancanbakir in projectdiscovery/subfinder#1820
* Refactored loadFromFile to use bufio.Scanner by @nandaanomi in projectdiscovery/subfinder#1791


## New Contributors
* @ChrisJr404 made their first contribution in projectdiscovery/subfinder#1787
* @Bundy01 made their first contribution in projectdiscovery/subfinder#1719
* @nandaanomi made their first contribution in projectdiscovery/subfinder#1791
* @jatinder14 made their first contribution in projectdiscovery/subfinder#1815
* @Gerijacki made their first contribution in projectdiscovery/subfinder#1812

**Full Changelog**: https://github.com/projectdiscovery/subfinder/compare/v2.14.0...v2.15.0</pre>
  <p>View the full release notes at <a href="https://github.com/projectdiscovery/subfinder/releases/tag/v2.15.0">https://github.com/projectdiscovery/subfinder/releases/tag/v2.15.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!16007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

source goroutines leak when enumeration is cancelled under backpressure

2 participants