-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Bugfix: Fix #15004 by applying MDN recommended fix when proxying Response in page_load #15005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix: Fix #15004 by applying MDN recommended fix when proxying Response in page_load #15005
Conversation
On Node v24+, the undici library used for HTTP has a Response class with a private element. Proxying the response therefore fails when calling clone() as the method returned by the proxy cannot access the private state element.
By using Object.defineProperty(), we make the function identical to introspection. Also, the linter didn't like the `...args`.
🦋 Changeset detectedLatest commit: 73bb122 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
programming is magic, we just have to say the correct incantations, and you can't convince me otherwise 😆
thanks for fixing this! really glad I didn't have to track this down myself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this was not fun to debug, I'm not going to lie 😄
Programs are basically spells, written in an arcane language decipherable only by those who study it closely, which we give breath to by running lightning through sand so yeah – if you showed this to someone from 1,000 years ago, you could not convince them that was it not magic
977b8bd
into
sveltejs:main
On Node v24+, the undici library used for HTTP has a Response class with a private element. Proxying the response therefore fails when calling clone() as the method returned by the proxy cannot access the private state element.
In the linked issue, I mention the MDN version of this fix using a simple
function (...any) { ... }but I opted for the slightly more comprehensive one usingReflect.apply()andObject.defineProperties()as it ensures the returned function is identical to introspection (according to nodejs/undici#4290 (comment), anyway).See: #15004.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
I included a page in the test apps that reproduces the error (only on Node v24+, obviously). You can reproduce this error by visiting this test page with the fix from this PR reverted.
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits