# Pocket-ic wasm size limit other than IC?

**URL:** <https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750>\
**Category:** Developers\
**Created:** [June 10, 2024, 1:43pm UTC](https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750 "2024-06-10T13:43:24Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![kristofer](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/kristofer/32/11135_2.png) [@kristofer](https://forum.dfinity.org/u/kristofer)\
**Post date:** [June 10, 2024, 1:43pm UTC](https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750/1 "2024-06-10T13:43:24Z")

</div>

Hi, does Pocket-ic have other restrictions on wasm size than IC in general. I have no problems running my canister locally or deploying to mainnet. But, when using pocket-ic:

```auto
Failed to submit ingress message: Request 0x73f6562d82a01782d062f91443751263bd72382d3fd4fa925bc4dadfebb6eeef is too large. Message byte size 2546230 is larger than the max allowed 2097152.

```

WASM ia gzipped already.

@michael-weigelt

---

<div class="post-metadata">

**Author:** ![mraszyk](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/mraszyk/32/7945_2.png) [@mraszyk](https://forum.dfinity.org/u/mraszyk)\
**Post date:** [June 10, 2024, 2:52pm UTC](https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750/2 "2024-06-10T14:52:05Z")

</div>

On an application subnet, the limit is at 2M just like in PocketIC. Locally, the request could work on a system subnet, but on mainnet, it won’t work on an application subnet. Which mainnet subnet were you targetting?

---

<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:** [June 10, 2024, 7:26pm UTC](https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750/3 "2024-06-10T19:26:04Z")

</div>

Given that you can deploy your canister both locally and on mainnet, did you double check that you actually pass correctly the Gzip file path to Pocket-ic and not inadvertently the path to the Wasm?

Stupid feedback but, you never know…

---

<div class="post-metadata">

**Author:** ![kristofer](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/kristofer/32/11135_2.png) [@kristofer](https://forum.dfinity.org/u/kristofer)\
**Post date:** [June 10, 2024, 8:04pm UTC](https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750/4 "2024-06-10T20:04:58Z")

</div>

> Given that you can deploy your canister both locally and on mainnet, did you double check that you actually pass correctly the Gzip file path to Pocket-ic and not inadvertently the path to the Wasm?

That could totally have happened! 😂 But not this time. The byte size specified in the message, 2,5 mb ca, is the compressed size. BoaEngine I believe take up a lot of that space.

I was under the impression the allowed WASM size for canisters had been raised quite significantly, back in January or there around. See here for instance:

> [@Wasm module is too large, it can be at most 31457280 bytes](https://forum.dfinity.org/t/wasm-module-is-too-large-it-can-be-at-most-31457280-bytes/27722):
>
> Hey so I thought that Wasm modules could be up to 100 MiB with 90 MiB of data section? Is that wrong? I’m trying to deploy a Wasm module that is 49 MiB using dfx 0.16.1 locally, should be mostly data section, and I get this error: Installing canisters... Upgrading code for canister backend, with canister ID bkyz2-fmaaa-aaaaa-qaaaq-cai Error: Failed while trying to deploy canisters. Caused by: Failed while trying to deploy canisters. Failed while trying to install all canisters. Failed to…

Also, for testing, I tried installing my canister unzipped to ic, 9+ mb, that worked without issue.

[https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.icp0.io/?id=mzakg-qaaaa-aaaal-qjesa-cai](https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.icp0.io/?id=mzakg-qaaaa-aaaal-qjesa-cai)

@mraszyk am I misunderstanding something here?

---

<div class="post-metadata">

**Author:** ![mraszyk](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/mraszyk/32/7945_2.png) [@mraszyk](https://forum.dfinity.org/u/mraszyk)\
**Post date:** [June 10, 2024, 8:24pm UTC](https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750/5 "2024-06-10T20:24:15Z")

</div>

If you use dfx to deploy your canister on mainnet, then dfx would chunk your WASM and upload the chunks in multiple update calls (using the so-called large WASM feature). PocketIC doesn’t do that yet which might be why you perceive a different behavior.

---

<div class="post-metadata">

**Author:** ![kristofer](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/kristofer/32/11135_2.png) [@kristofer](https://forum.dfinity.org/u/kristofer)\
**Post date:** [June 10, 2024, 8:40pm UTC](https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750/6 "2024-06-10T20:40:11Z")

</div>

Ah, thanks. Will PocketIC implement chunking in the future so larger canisters can be tested as well?

---

<div class="post-metadata">

**Author:** ![mraszyk](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/mraszyk/32/7945_2.png) [@mraszyk](https://forum.dfinity.org/u/mraszyk)\
**Post date:** [June 10, 2024, 9:07pm UTC](https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750/7 "2024-06-10T21:07:57Z")

</div>

Just to double check: are you using the `PocketIc::install_canister` library function in the Rust PocketIC library?

---

<div class="post-metadata">

**Author:** ![kristofer](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/kristofer/32/11135_2.png) [@kristofer](https://forum.dfinity.org/u/kristofer)\
**Post date:** [June 10, 2024, 9:10pm UTC](https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750/8 "2024-06-10T21:10:42Z")

</div>

Yup.

```Rust
use candid::{decode_one, Principal};
use catts_engine::Recipe;
use pocket_ic::{PocketIc, WasmResult};
use std::fs;

const CANISTER_WASM: &str = "../../target/wasm32-wasi/release/catts_engine.wasm.gz";

fn setup() -> (PocketIc, Principal) {
    let pic = PocketIc::new();
    let canister = pic.create_canister();
    pic.add_cycles(canister, 2_000_000_000_000); // 2T Cycles
    let wasm = fs::read(CANISTER_WASM).expect("Wasm file not found, run 'dfx build'.");
    pic.install_canister(canister, wasm, vec![], None);
    (pic, canister)
}

#[test]
fn test_recipe_list() {
    let (pic, catts) = setup();

    let Ok(WasmResult::Reply(response)) =
        pic.query_call(catts, Principal::anonymous(), "recipe_list", vec![])
    else {
        panic!("Expected reply");
    };

    let result: Vec<Recipe> = decode_one(&response).unwrap();
    
    // do some assertions
}

```

---

<div class="post-metadata">

**Author:** ![kristofer](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/kristofer/32/11135_2.png) [@kristofer](https://forum.dfinity.org/u/kristofer)\
**Post date:** [June 11, 2024, 7:51am UTC](https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750/9 "2024-06-11T07:51:48Z")

</div>

Some parts can of course be unit tested. But, all parts that require ic specific features would need to be mocked, which is quite messy. I am surprised not more devs have run into this. Maybe testing of canisters is not a big thing.

To begin with I’ll try replacing the JS runtime I use in the canister to see if I can squeeze size below limit. That was the plan anyway. Large wasm support further on would be fantastic though!

---

<div class="post-metadata">

**Author:** ![mraszyk](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/mraszyk/32/7945_2.png) [@mraszyk](https://forum.dfinity.org/u/mraszyk)\
**Post date:** [June 12, 2024, 9:24am UTC](https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750/10 "2024-06-12T09:24:04Z")

</div>

> [@kristofer](#):
>
> Large wasm support further on would be fantastic though!

I’m optimistic that it’s easy to add it and will look into this soon.

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [December 10, 2024, 2:56am UTC](https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750/11 "2024-12-10T02:56:21Z")

</div>

@mraszyk

> **Edited**
>
> Any updates on this? I’m running into this with pic.js 10.0…my wasm zipped is just over the limit. It has another actor that it deploys. I can pull that out from a reference and upload the bytes into the canister after deploy, but this will extend the setup time and is just generally annoying to have to do.

I see that it was added in 5.0.0, but I’m guessing that pic may not be using it. I’ll investigate.

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [December 10, 2024, 3:11am UTC](https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750/12 "2024-12-10T03:11:44Z")

</div>

Looks like we need a function to encode the install\_chunked\_code\_args in [pic-js/packages/pic/src/management-canister.ts at main · hadronous/pic-js · GitHub](https://github.com/hadronous/pic-js/blob/main/packages/pic/src/management-canister.ts) and and some smarts in [pic-js/packages/pic/src/pocket-ic.ts at b5f394a3d857ea5017727f96977b55cba54bddcc · hadronous/pic-js · GitHub](https://github.com/hadronous/pic-js/blob/b5f394a3d857ea5017727f96977b55cba54bddcc/packages/pic/src/pocket-ic.ts#L363) to look at the size and call install\_chunked\_code instead.

I’m curious what the store\_canister is/does and what the sender\_canister\_version might need to be.

---

<div class="post-metadata">

**Author:** ![mraszyk](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/mraszyk/32/7945_2.png) [@mraszyk](https://forum.dfinity.org/u/mraszyk)\
**Post date:** [December 10, 2024, 7:37am UTC](https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750/13 "2024-12-10T07:37:21Z")

</div>

- the `store_canister` is the canister ID of the canister that hosts the chunks (it can be the same canister as the installed canister or a different canister on the same subnet)
- the `sender_canister_version` must not be set for ingress message (it could only be set for inter-canister calls as the sender’s _canister version_ returned by the `ic0.canister_version` system API before making the inter-canister call)

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [April 26, 2025, 12:24am UTC](https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750/14 "2025-04-26T00:24:36Z")

</div>

> [@mraszyk](#):
>
> the `store_canister` is the canister ID of the canister that hosts the chunks (it can be the same canister as the installed canister or a different canister on the same subnet)

Maybe a dumb question here, but can upload\_chunk\_args be called on any canister that you are a controller on even if the canister is stopped? Or does it have to be a canister that is running and has some endpoint? the subnet thing makes this tricky if you can’t do it for a stopped canister that you are installing code to.

---

<div class="post-metadata">

**Author:** ![mraszyk](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/mraszyk/32/7945_2.png) [@mraszyk](https://forum.dfinity.org/u/mraszyk)\
**Post date:** [April 26, 2025, 2:26pm UTC](https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750/15 "2025-04-26T14:26:57Z")

</div>

> [@skilesare](#):
>
> Maybe a dumb question here, but can upload\_chunk\_args be called on any canister that you are a controller on even if the canister is stopped?

Indeed, chunks can be uploaded also to the wasm chunk store of a stopped canister (since the call to do so targets the management canister which is never stopped).

---

<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:** [May 23, 2025, 6:20pm UTC](https://forum.dfinity.org/t/pocket-ic-wasm-size-limit-other-than-ic/31750/16 "2025-05-23T18:20:37Z")

</div>

I ran into the large WASM issue in Juno today. I forked `pic-js` and started working on a PR, but quickly realized it would take more time than I had anticipated. I’m currently working a large feature that still needs iterations and as always, it feels like I’m behind schedule, so I had to put together a workaround instead to move forward.

Long story short: if you’ve landed here and need a way to install large WASM files with `pic-js` before official support lands, here are a few functions you can drop into your project to get it working.

> <https://github.com/junobuild/juno/blob/main/src/tests/utils/pic-setup-tests.utils.ts>

Maybe someday, if I find a bit more time and the feature still isn’t available, I’ll circle back and finish that PR.
