`installV3ShadowPiercer` ignores `opts.debug` — debug logging always enabled

Open Beginner friendly
#1,996 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript
Domain
devtools

Research direction

Start in packages/core/lib/v3/dom/piercer.runtime.ts at installV3ShadowPiercer and inspect how opts.debug is currently handled. Verify that the default disables attachShadow logging, while explicitly enabling debug preserves it. Done means the option controls the logging behavior without changing other shadow-piercer options.

Written by the indexing model from the issue text.

Description

Bug:installV3ShadowPiercer 中的 opts.debug 被忽略

文件: packages/core/lib/v3/dom/piercer.runtime.ts

V3ShadowPatchOptions 接口中定义了一个 debug?: boolean 选项:

export interface V3ShadowPatchOptions {
  debug?: boolean;
  tagExisting?: boolean;
}

但是,installV3ShadowPiercer 并没有使用 opts.debug,而是将
DEBUG 硬编码为 true,并在注释中也承认了这一点:

export function installV3ShadowPiercer(opts: V3ShadowPatchOptions = {}): void {
  // hardcoded debug (remove later if desired)
  const DEBUG = true;

这意味着无论调用方传入什么参数,console.info("[v3-piercer] attachShadow", ...)
都会在每次调用 attachShadow 时触发,V3ShadowPatchOptions 中的 debug 字段实际上成为了一个无效(未被使用)的 API。

期望行为:
DEBUG 应该基于 opts.debug ?? false 来设置,从而允许调用方控制日志输出的详细程度。

建议修复:

const DEBUG = opts.debug ?? false;
Dominant language
TypeScript
Stars
24.6k
Forks
1.7k
Avg merge
4d 2h
Merged PRs (30d)
62

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from browserbase/stagehand

All issues in browserbase/stagehand

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.