build error: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object
See original GitHub issueHi,
I have a project with an older version of cbor (5.0.1). First off, I have tried to update to the latest version (7.0.5) but that didn’t fix the issue, and yields another issue at build time, with rollup, so I’d rather not go down that path just yet.
The issue occurs in a jest environment, when testing the build code. That is, if I run a test against the source code, there is no issue and I get the correct output.
If I test against the build code, then this error arises:
First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object
with the stack call as follows
fromObject (dist/decoder-es.js:480:9)
at from (dist/decoder-es.js:314:10)
at new subarray (dist/decoder-es.js:290:10)
at Uint8Array.subarray (<anonymous>)
at Uint8Array.slice (dist/decoder-es.js:1249:19)
at fromListPartial (dist/decoder-es.js:4209:26)
at fromList (dist/decoder-es.js:4196:11)
at NoFilter.Object.<anonymous>.Readable.read (dist/decoder-es.js:3746:20)
at NoFilter.read (dist/decoder-es.js:8626:14)
at Object.decode [as decodeFirstSync] (dist/decoder-es.js:10726:19)
at decode (dist/decoder-es.js:30392:22)
at Object.<anonymous> (test/build.es.test.js:7:24)
I have set up a repro here if that helps: https://github.com/lemoustachiste/repro-cbor-build. It seems to me that it was until recently working (albeit not in this repo), but I am not capable to identify what changed so maybe you can help me get on the right tracks.
The entry point is here: https://github.com/lemoustachiste/repro-cbor-build/blob/master/src/index.js#L97
Thanks
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (8 by maintainers)
Top GitHub Comments
OK, i’ve got it. Use
decode(encoded, {preferWeb: true})
, then in the places where you are looking for Buffer, look for Uint8Array. The environment that the babel’d code is running in is using slightly different Buffer implementations, but the native Uint8Arrays will make it through all of that cleanly.I have isolated the issue to the type of the
value
property, so evenpreferWeb
is not required. For all intent of purposes I’d say this issue is resolved so I am going to close.Thanks again @hildjj