# Agent-js stdlib.Uint8Array is not a constructor

**URL:** <https://forum.dfinity.org/t/agent-js-stdlib-uint8array-is-not-a-constructor/27031>\
**Category:** Developers\
**Created:** [January 27, 2024, 10:57am UTC](https://forum.dfinity.org/t/agent-js-stdlib-uint8array-is-not-a-constructor/27031 "2024-01-27T10:57:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [January 27, 2024, 10:57am UTC](https://forum.dfinity.org/t/agent-js-stdlib-uint8array-is-not-a-constructor/27031/1 "2024-01-27T10:57:09Z")

</div>

What’s that agent-js error while trying to perform a query locally?

> chunk-AL5F2A5A.js?v=8c176263:3155 Uncaught (in promise) TypeError: stdlib.Uint8Array is not a constructor  
> at decodeAsm (chunk-AL5F2A5A.js?v=8c176263:3155:18)  
> at new \_Decoder (chunk-AL5F2A5A.js?v=8c176263:4972:23)  
> at new Uint8ArrayDecoder (chunk-AL5F2A5A.js?v=8c176263:6675:25)  
> at decode (chunk-AL5F2A5A.js?v=8c176263:6688:19)  
> at \_HttpAgent.status (@dfinity\_agent.js?v=0f04bff6:4504:12)  
> at async \_HttpAgent.fetchRootKey (@dfinity\_agent.js?v=0f04bff6:4508:23)  
> at async ve (actor.api.ts:40:5)  
> at async jt (satellite.api.ts:127:26)  
> at async HTMLButtonElement.version (admin.ts:8:5)

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [January 27, 2024, 11:15am UTC](https://forum.dfinity.org/t/agent-js-stdlib-uint8array-is-not-a-constructor/27031/2 "2024-01-27T11:15:01Z")

</div>

Node dependencies s\*\*\* as usual.

“Solved” by polyfilling the required `stdlib.Uint8Array` inherited by cbor using `@esbuild-plugins/node-modules-polyfill`.

If anyone lands on this in the future, note the above works out only for development.

---

<div class="post-metadata">

**Author:** ![iamenochchirima](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/iamenochchirima/32/21673_2.png) [@iamenochchirima](https://forum.dfinity.org/u/iamenochchirima)\
**Post date:** [February 28, 2024, 1:31pm UTC](https://forum.dfinity.org/t/agent-js-stdlib-uint8array-is-not-a-constructor/27031/3 "2024-02-28T13:31:13Z")

</div>

Hi @peterparker , i’m getting the same problem, how exactly do I “polyfill” the required stdlib.Uint8Array inherited by cbor.

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [February 28, 2024, 1:59pm UTC](https://forum.dfinity.org/t/agent-js-stdlib-uint8array-is-not-a-constructor/27031/4 "2024-02-28T13:59:26Z")

</div>

The solution depends what bundler you are using (vite, rollup, webpack etc.) - i.e. which plugin you gonna use and how you gonna use it is tailored for your bundler but, generally speaking, you have to configure your bundler with plugins to polyfill those NodeJS dependencies that are not meant for the browser.
