# Frontend Canister Upgrade Fails with 'malformed\_request'

**URL:** https://forum.dfinity.org/t/frontend-canister-upgrade-fails-with-malformed-request/49257
**Category:** Language Support
**Tags:** Wasm
**Created:** [May 28, 2025, 8:18pm UTC](https://forum.dfinity.org/t/frontend-canister-upgrade-fails-with-malformed-request/49257 "2025-05-28T20:18:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Nimakra](https://avatars.discourse-cdn.com/v4/letter/n/aeb1de/32.png) [@Nimakra](https://forum.dfinity.org/u/Nimakra)
#### Post date: [May 28, 2025, 8:18pm UTC](https://forum.dfinity.org/t/frontend-canister-upgrade-fails-with-malformed-request/49257/1 "2025-05-28T20:18:24Z")

</div>

Hello everyone, I have a React + Vite frontend already deployed to the mainnet. My build output is in `dist/`. The assets **folder** in `dist/assets` contains all of my app’s compiled JS files. This folder is about 2.9MB in total, with some individual **files** as large as 900KB each. Assets are already gzip-compressed.

When I try to upgrade or reinstall this frontend canister (`dfx canister install --mode upgrade --network ic`), I get this error:

```auto
Failed to create chunks
The replica returned an HTTP Error: status 400 Bad Request
error: malformed_request
details: HTTP body reading timed out

```

Interestingly, if I remove a few large files to bring the `dist/assets` under 2MB, the deploy works fine (my frontend can’t display properly without those files, though). I have enough cycles to run the commands.

Could this be because of the 2MB limit? I thought it applied to individual files, and none of my **files** are over 1MB. Any workaround for this issue?

---

<div class="post-metadata">

### Author: ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)
#### Post date: [May 30, 2025, 9:41am UTC](https://forum.dfinity.org/t/frontend-canister-upgrade-fails-with-malformed-request/49257/2 "2025-05-30T09:41:52Z")

</div>

No, if file size was an issue you would not get `malformed_request` but something like `ingress message size exceeded limit`. I do not know what this could stem from. Does this reliably happen? Could you send me a reproduction?

---

<div class="post-metadata">

### Author: ![Nimakra](https://avatars.discourse-cdn.com/v4/letter/n/aeb1de/32.png) [@Nimakra](https://forum.dfinity.org/u/Nimakra)
#### Post date: [June 5, 2025, 4:21pm UTC](https://forum.dfinity.org/t/frontend-canister-upgrade-fails-with-malformed-request/49257/3 "2025-06-05T16:21:54Z")

</div>

Yes, it happens every time whenever the total size of the dist/assets is above 2MB. It only works if I remove a few individual JS bundles that are 700-900kb, which brings the total size of the folder below 2MB.

I have created a minimal reproduction here: [GitHub-repo](https://github.com/Nimakra/frontend-repo)  
It includes the actual compiled dist/ folder.

Note that, however, it works fine locally, both upgrading and deploying. The error only occurs when deploying to mainnet.
