Skip to content

feat(hybrid): expose the crawl's BrowserContextID - #1839

Merged
dogancanbakir merged 1 commit into
projectdiscovery:devfrom
sullo:feat/hybrid-browser-context-id
Sep 29, 2026
Merged

dogancanbakir merged 1 commit into
projectdiscovery:devfrom
sullo:feat/hybrid-browser-context-id

Conversation

@sullo

@sullo sullo commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Proposed changes

hybrid.New creates a browser context per crawler (Target.createBrowserContext, since #1751) but the id is never exposed, so a program embedding katana cannot dispose that context out of band.

That matters when katana attaches to a shared, long-lived browser over -chrome-ws-url: if a crawl's process dies without reaching Close, the context stays resident and holds the browser's memory for a crawl that no longer exists. With the id recorded, a supervisor can reap orphaned contexts.

Read-only accessor, 11 lines, no behaviour change.

func (c *Crawler) BrowserContextID() string

Checklist

  • Builds (go build ./..., go vet ./pkg/engine/hybrid/)
  • No behaviour change, so no test added

Summary by CodeRabbit

  • New Features
    • Added access to the browser context identifier associated with each crawl.
    • The identifier is available for external browser-context management when needed.
    • Returns an empty value when no browser context is available, providing predictable behavior for crawls without an active browser.

@neo-by-projectdiscovery-dev

neo-by-projectdiscovery-dev Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Neo - PR Security Review

No exploitable security issues in this delta — the two changed lines are a blank-line removal and a doc-comment reword with zero impact on behavior or attack surface.

What Neo reviewed

pkg/engine/hybrid/hybrid.go

Comment @pdneo help for available commands. · Open in Neo

@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: d977fbb5-7c21-40e1-a1f3-a095bbaac368

📥 Commits

Reviewing files that changed from the base of the PR and between b8cd277 and f992703.

📒 Files selected for processing (1)
  • pkg/engine/hybrid/hybrid.go

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


Walkthrough

The crawler now exposes its browser context ID through a new exported method. The method returns an empty string when no browser is configured.

Changes

Browser context access

Layer / File(s) Summary
Context ID accessor
pkg/engine/hybrid/hybrid.go
Adds Crawler.BrowserContextID(), which returns the browser context ID or an empty string when c.browser is nil.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Feature

Suggested reviewers: mzack9999

Merge Risk: ⚪ Minimal · up to f9927

This is a small read-only API addition with no identified merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: exposing the crawler's BrowserContextID through the hybrid engine API.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

A rabbit hops where browser contexts glow
It gathers the ID before tunnels close
If no browser waits nearby
An empty string goes by
Clean paths help the crawler know

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

New creates a browser context per crawler but never surfaces its id, so an
embedding program cannot dispose the context out of band. That matters against
a shared, long-lived browser reached over -chrome-ws-url: if a crawl's process
dies without running Close, the context stays resident and consumes the
browser's memory for a crawl that no longer exists.

Adds a read-only accessor; no behaviour change.
@sullo
sullo force-pushed the feat/hybrid-browser-context-id branch from b8cd277 to f992703 Compare September 12, 2026 04:42
@dogancanbakir
dogancanbakir merged commit 29f4d1c into projectdiscovery:dev Sep 29, 2026
14 checks passed
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.

2 participants