fix: preserve vendor API method receivers#843
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
📝 WalkthroughWalkthroughAdds Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/script/src/runtime/script-api.ts`:
- Around line 61-63: Update the result handling around bindScriptApiMethods to
detect Promises across browser realms using the standard Promise tag rather than
instanceof Promise. Preserve direct binding for non-Promise results, and apply
result.then(bindScriptApiMethods) for both same-realm and cross-realm Promises.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ac4959a7-3872-4068-ae1b-6242a5e05bc2
📒 Files selected for processing (4)
packages/script/src/runtime/composables/useScript.tspackages/script/src/runtime/script-api.tstest/nuxt-runtime/proxy-receiver.nuxt.test.tstest/unit/script-api.test.ts
Linked issue
Type of change
Description
Methods returned by
use()can run with Unhead's forwarding proxy asthis. Firefox then rejects native DOM calls such as JSConfetti's canvasgetBoundingClientRect()call.Wrap synchronous and Promise based
use()results with stable, receiver safe method proxies before passing them to Unhead. This includes Promises created in another browser realm. Unit and Nuxt runtime tests cover the failures. This protects Nuxt Scripts users on supported Unhead releases while the root fix lands upstream.Verification
pnpm lintpnpm typecheckpnpm buildpnpm test:run, 963 tests passed