Frontend Canister Upgrade Fails with 'malformed_request'

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:

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?

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?

1 Like

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
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.

1 Like