Skip to content
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

body mixin returns Uint8Array instead of ArrayBuffer #2343

Closed
terminal69 opened this issue Oct 12, 2023 · 1 comment · Fixed by #2344
Closed

body mixin returns Uint8Array instead of ArrayBuffer #2343

terminal69 opened this issue Oct 12, 2023 · 1 comment · Fixed by #2344
Labels
bug Something isn't working

Comments

@terminal69
Copy link

Bug Description

According to the documentation the body mixin arrayBuffer() should return Promise, however it returns Promise.

References:
https://github.com/nodejs/undici/blob/main/docs/api/Dispatcher.md#dispatcherrequestoptions-callback
https://fetch.spec.whatwg.org/#body-mixin

Reproducible By

❯ node
Welcome to Node.js v18.18.0.
Type ".help" for more information.
> const undici = require('undici')
undefined
> const response = await undici.request("https://echo.free.beeceptor.com/")
undefined
> const buffer = await response.body.arrayBuffer();
undefined
> typeof buffer
'object'
> buffer instanceof ArrayBuffer
false
> buffer instanceof Uint8Array
true
> typeof buffer.buffer
'object'
> buffer.buffer instanceof ArrayBuffer
true
>

Expected Behavior

Not sure if this is a bug or expected behaviour however the documentation should at least reflect this

Environment

Fedora 38
linux kernel 6.6.0-0.rc4
nodejs 18.18.0
undici@5.24.0

Additional context

If this is a bug that has been present for a long time then fixing it may need to be classified as a breaking change

@terminal69 terminal69 added the bug Something isn't working label Oct 12, 2023
@terminal69
Copy link
Author

Reproduced on undici@5.26.3

> let promiseBuffer = response.body.arrayBuffer()
undefined
> promiseBuffer
Promise {
  Uint8Array(336) [
    ...
  ],
  [Symbol(async_id_symbol)]: 1095,
  [Symbol(trigger_async_id_symbol)]: 6
}
>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant