projectdiscovery/katana · error

captcha solve: %w

Error message

captcha solve: %w

What it means

solveCaptcha delegates to the configured solver's Solve; any failure there (timeout, CapSolver API error, missing token, network error) is wrapped with this prefix. It means a captcha was detected on the page and solving was attempted, but no usable token was produced.

Source

Thrown at pkg/engine/headless/captcha/captcha.go:51

	info, err := Identify(page)
	if err != nil {
		gologger.Debug().Msgf("captcha identification failed: %s", err)
	}

	if info == nil {
		return false, nil
	}

	return h.solveCaptcha(ctx, page, info)
}

func (h *Handler) solveCaptcha(ctx context.Context, page *rod.Page, info *Info) (bool, error) {
	gologger.Debug().Msgf("captcha detected: provider=%s sitekey=%s url=%s", info.Provider, info.SiteKey, info.PageURL)

	solution, err := h.solver.Solve(ctx, info)
	if err != nil {
		return true, fmt.Errorf("captcha solve: %w", err)
	}

	gologger.Debug().Msgf("captcha solved, injecting token: provider=%s", solution.Provider)

	if err := injectToken(page, solution); err != nil {
		return true, fmt.Errorf("captcha inject: %w", err)
	}

	return true, nil
}

func injectToken(page *rod.Page, solution *Solution) error {
	js, err := injectionScript(solution.Provider)
	if err != nil {
		return err
	}
	_, err = page.Eval(js, solution.Token)
	return err

View on GitHub (pinned to e3e742739c)

Solutions

  1. Unwrap the chain (%w) to find the root cause (timeout vs API error vs missing token)
  2. Validate the solver API key and balance before the crawl
  3. Raise the context deadline (solve budget is 120s)
  4. Configure a fallback solver or disable captcha solving for targets that reliably fail
  5. Retry the page once with a fresh context
Defensive patterns

Strategy: try-catch

Validate before calling

if handler == nil {
	// captcha solving not configured; skip HandleIfCaptcha
}

Try / catch

handled, err := handler.HandleIfCaptcha(ctx, page, html)
if err != nil {
	log.Printf("captcha handling failed (continuing): %v", err)
	// decide: skip target or proceed unsolved
}

Prevention

When it happens

Trigger: Called by HandleIfCaptcha after detection identifies a captcha; wraps every error the solver returns, including capsolver timeouts/errors, missing tokens, unsupported providers, and HTTP failures.

Common situations: Expired/invalid solver API key; CapSolver outage; captcha type the solver cannot handle; crawl context cancelled mid-solve; low balance.

Related errors


AI-assisted analysis of projectdiscovery/katana@e3e742739c (2026-09-03). Data as JSON: /api/errors/3bc50384a9266682. Report an issue: GitHub.