-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
rest: prefer arrayBuffer over buffer #7318
Conversation
Also pinging @ckohen since they're pretty involved in rest |
At first glance, I'm inclined to not make this switch until we utilize undici because of the way node-fetch handles consuming the body. Internally, node-fetch seems to much prefer using buffer() since that is what their consume function converts to natively (Their consume body function probably is why buffer() exists at all). While small, there is a slight performance hit from converting that buffer, not sure if that's going to end up mattering much though. I guess its a matter of if we want to do part of the work now rather than later (also makes undici a semver:minor / patch PR I think?) which is up to the maintainers. To note: should be obvious, but this will need changes in the main lib in #7298 |
I doubt that this change will have any meaningful performance impact, as node-fetch's arrayBuffer method is simply just using The only difference is that users will have to deal with ArrayBuffers instead of Buffers on api routes that don't have an |
Yeah, slight could definitely be considered an exaggeration for the performance implications lol, especially considering the slim amount of endpoints that don't return JSON to begin with |
converting it to a node buffer have not so much cost to it i think, const buffer = await res.arrayBuffer().then(Buffer.from) But ultimately i think buffer should be discouraged for better cross platform functionality |
Can you rebase this PR? @KhafraDev |
@iCrawl rebased 👍 |
Please describe the changes this PR makes and why it should be merged:
Response.buffer
is not a spec compliant method.I have no idea if types need updating, sorry 😕
Status and versioning classification: