Closed JackFromMoo closed 3 months ago
I'm having this exact same issue, with exact same setting of Vue.js with Webpack. After some digging, I found out that it's caused by using ancient version of https://github.com/feross/buffer.
aws-sdk-js-v3 requires buffer version 5.6.0, which can properly handle UIntArray8, so it's not to blame.
The code you pasted in the issue is identical to what's found in mine, which is 4.9.2 released in 2019, so it's the same version or even older.
For me, the root cause was the old nuxt version, and the chain is like this:
nuxt: ^2.16.3 @nuxt/webpack: ^2.16.3 webpack: ^4.46.0 node-libs-browser:^2.2.1 buffer: ^4.3.0
Thanks @harfangk, you're absolutely right that that's where the problem lies. I've been learning a ton about webpack and dependencies as I've been troubleshooting this. Hopefully the closed issue will help people with the same problem in the future.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.
Checkboxes for prior research
Describe the bug
Attempting to pass a Blob such as a File as the options.params.body of an Upload will result in an error if the file is large enough to trigger a multipart upload. This issue will impacts some webpack users building their apps for browser.
The error is:
TypeError: "list" argument must be an Array of Buffers
This bug was introduced in pull request #5078The root of the error is from the node-libs-browser implementation of Node's buffer, node-libs-browser. This library uses https://github.com/feross/buffer for its implementation of buffer.
When
lib/lib-storage/src/chunks/getChunkStream.ts
callsBuffer.concat(currentBuffer.chunks)
on line 27, it produces the error. This is becausecurrentBuffer.chunks
is populated bylib/lib-storage/src/chunks/getDataReadableStream.ts
, which was changed in the pull request.getDataReadableStream.ts
used to only produce Buffers, but the pull request allowed it to also return values that are instances of Uint8Array. The browser implementation ofBuffer.concat()
explicitly checks each element of the given Array usingBuffer.isBuffer(element)
, which will return false if "element" is a Uint8Array.SDK version number
@aws-sdk/lib-storage@v3.532.0+
Which JavaScript Runtime is this issue in?
Browser
Details of the browser/Node.js/ReactNative version
Browser is Chrome Version 122.0.6261.139 (Official Build) extended (64-bit)
Reproduction Steps
Not sure how to provide a snippet since my code's a Vue app built using Webpack. Note that you probably will not be able to reproduce this in Node since the base Node Buffer.concat() will probably accept Uint8Arrays as elements. I assume this is how the pull request was accepted.
Simply use lib-storage, create a new Upload(), and have the options.params.body be a File object such as that from an HTML
Observed Behavior
The error:
TypeError: "list" argument must be an Array of Buffers at c.concat (index.js:399:13) at getChunkStream.js:9:72 at f (getChunkStream.js:2:1) at Generator.<anonymous> (getChunkStream.js:2:1) at Generator.next (getChunkStream.js:2:1) at n (getChunkStream.js:2:1) at getChunkStream.js:2:1
Browser implementation of Buffer.concat: