Skip to content

Bug : v3Logger fallback bypasses verbose level filtering, causing debug logs even with verbose: 0 #1490

@sashank-zluri

Description

@sashank-zluri

Bug Description

When using Stagehand V3 with verbose: 0, debug-level logs like DEBUG: xpath main-world are still printed to the console. The v3Logger function has a fallback path that bypasses verbose level filtering.

Steps to Reproduce

import { Stagehand } from "@browserbasehq/stagehand";

const stagehand = new Stagehand({
  env: "LOCAL",
  verbose: 0,  // Errors only
  disablePino: true,
});

await stagehand.init();
const page = stagehand.context.pages()[0];
await page.goto("https://example.com");
// Use any locator/xpath operation
await page.locator("//div").first();

Expected Behavior

With verbose: 0, only error-level logs should be printed. Debug logs should be suppressed.

Actual Behavior

Debug logs are printed:

[2026-01-02T13:16:37.661Z] DEBUG: xpath main-world
    frameId: F6611B8D017F9801E6E83A956066C58D
    xp: /html/body[1]/div[1]/div[3]/main[1]/div[1]/div[2]/form[1]/div[1]/input[2]
    ctxId: 3

Root Cause Analysis

In lib/v3/logger.ts, the v3Logger function has two code paths:

  1. Instance logger path (lines ~500-510): Calls the registered instance logger which respects verbose level
  2. Fallback path (lines ~514-540): Directly logs to console without checking verbose level

The fallback path logs to console regardless of configured verbosity:

if (lvl === 2) {
  (console.debug ?? console.log)(output);  // No verbose check!
}

Meanwhile, StagehandLogger.log() correctly checks: if (logLine.level > this.verbose) return;

Suggested Fix

The fallback path in v3Logger should either:

  1. Not log at all when no instance logger is registered (let it be silent)
  2. Or check against a global/default verbose level before logging

Environment

  • Stagehand version: latest (V3)
  • Node.js version: 22
  • OS: Alpine Linux (Docker) / macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions