fix: respect opts.debug in installV3ShadowPiercer (fixes #1996)#2069
fix: respect opts.debug in installV3ShadowPiercer (fixes #1996)#2069kagura-agent wants to merge 1 commit into
Conversation
…1996) Replace hardcoded `const DEBUG = true` with `const DEBUG = opts.debug ?? false` so callers can control debug logging via V3ShadowPatchOptions.
🦋 Changeset detectedLatest commit: 5c2f895 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run. |
There was a problem hiding this comment.
No issues found across 2 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Caller as Calling Service/Script
participant Piercer as installV3ShadowPiercer
participant DOM as Element.prototype
participant Console as Browser Console
Note over Caller,DOM: Initialization Phase
Caller->>Piercer: installV3ShadowPiercer(opts)
Piercer->>Piercer: CHANGED: Evaluate DEBUG via opts.debug ?? false
Piercer->>DOM: Patch attachShadow() logic
DOM-->>Piercer: Done
Piercer-->>Caller: Void
Note over Caller,DOM: Runtime Execution Phase
participant App as Web Application
App->>DOM: element.attachShadow(init)
alt DEBUG is true
DOM->>Console: NEW: Log "[v3-piercer] attachShadow"
else DEBUG is false
Note over DOM,Console: No logging output
end
DOM->>DOM: Execute original attachShadow
DOM->>DOM: Track shadow root in window.__v3ShadowRoots
DOM-->>App: shadowRoot
|
Friendly ping — this has been open for about a week. Happy to address any feedback or adjust the approach if needed. 🙂 |
|
Hey 👋 gentle ping — is there anything I should adjust in this PR? Happy to make changes if needed. |
|
Closing this as it's been open for 9 days with no maintainer feedback. Happy to reopen if/when you'd like to revisit — the fix is straightforward to re-apply. Thanks! 🙏 |
Problem
installV3ShadowPiercerdeclares adebug?: booleanoption inV3ShadowPatchOptions, but ignores it —DEBUGis hardcoded totrue:This means
console.info("[v3-piercer] attachShadow", ...)fires on everyattachShadowcall regardless of what the caller passes, and thedebugfield inV3ShadowPatchOptionsis effectively dead API.Fix
One-line change. Defaults to
false(no debug noise) and respects the caller's choice when explicitly set.Closes #1996.
Summary by cubic
Respect
opts.debugininstallV3ShadowPiercerby replacing the hardcodedDEBUG = truewithconst DEBUG = opts.debug ?? false. This removes noisy logs by default and lets callers enable debugging when needed (fixes #1996).Written for commit 5c2f895. Summary will update on new commits. Review in cubic