Repository navigation
Fix browser grab failing on Zone.js pages - #9995
Conversation
Zone.js patches the global Promise with a non-native thenable. When a bare
`new Promise(...)` crosses the Electron executeJavaScript boundary, it's
serialized as-is, losing { page, target } and exposing __zone_symbol__*
fields instead. Wrap in an async IIFE to return a native promise that
Electron always unwraps correctly.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughRefactors the injected 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…#9995) Zone.js patches the global Promise with a non-native thenable. When a bare `new Promise(...)` crosses the Electron executeJavaScript boundary, it's serialized as-is, losing { page, target } and exposing __zone_symbol__* fields instead. Wrap in an async IIFE to return a native promise that Electron always unwraps correctly.
Summary
Fixes issue #9947 where browser grab fails on pages using Zone.js-patched Promise. Zone.js replaces the global
Promisewith a non-native thenable; Electron'sexecuteJavaScriptboundary only unwraps native promises, so the wrapper object (with__zone_symbol__*fields) was serialized instead of the payload. Wrapping the promise-returning code in an async IIFE ensures it returns a native intrinsic promise that Electron always handles correctly.Screenshots
No visual change.
Testing
pnpm buildAI Review Report
The fix is surgical: wrapping
AWAIT_CLICK_SCRIPTin an async IIFE to ensure a native promise boundary crossing. Tests comprehensively model Zone.js's ZoneAwarePromise wrapper, verify all code paths (click, context menu, cancellation, rejection), and confirm serialization of the raw wrapper object is blocked.Cross-platform verified: the fix is platform-agnostic—it addresses Electron's promise boundary and Zone.js behavior, not platform-specific paths, shortcuts, or shell behavior.
Security Audit
No new attack surfaces. Error handling is preserved; input validation remains with
clampGrabPayload. Tests verify correct boundary crossing for both valid payloads and error cases.Notes
This fixes compatibility with pages using Zone.js, primarily Angular applications. No impact on pages that don't patch
Promise.