Total size exceeds the maximum allowed

I am working on some property tests for Azle and in one of the tests we have some very large canisters being generated. We keep getting the following error:

The replica returned a rejection error: reject code CanisterError, reject message Error from Canister bkyz2-fmaaa-aaaaa-qaaaq-cai: Canister’s Wasm module is not valid: Wasm module has an invalid custom section. Invalid custom sections: total size of the custom sections exceeds the maximum allowed: size 1135213 bytes, allowed 1048576 bytes.
This is likely an error with the compiler/CDK toolchain being used to build the canister. Please report the error to IC devs on the forum: https://forum.dfinity.org and include which language/CDK was used to create the canister., error code None

I was hoping someone might be able to help me get some clarification on this error

1 Like

Just adding to the OP, I would like to know what custom sections it is talking about…I assume this is the custom metadata? So is it possibly that our candid string stored in the custom metadata is too large? Is there a reason the custom section limit is so small?

Catching up on the forums tonight and it seems like we’re facing some hurdles with Azle? In another post, I raised the question of whether tools like this are essential for ICP’s success because of the instruction limit. Honestly, I’m concerned they might hurting our potential in the long run. We are building on revolutionary technology. I think its fair that developers adapt…

I thought the limit on custom sections was way higher, around 90MB. Is this on a local replica with an old version of dfx?

Custom sections have indeed a limit of 1MB, even though Wasm binary can be up to 100MB:

I think the reason for this limit is that custom sections are served in the state tree and users can query them, so custom sections consume more resources than the rest of the Wasm binary:

@bdemann: what do you store in the custom section? Can that be stored in data section instead?

My guess is it’s the Candid, these tests generate very large random canisters, so I assume the Candid generated and stored in the Candid section of the custom metadata is quite large… actually did we check @bdemann ? I thought you said it was ~400 KiB of Candid?

So if it is the Candid, we kind of can’t do it anywhere else. This is just from one of our property tests that is really pushing things to the limit, so not blocking us that I know of, but still…

Interesting! I would love to see the 400K did file, never seen one in my life…

Since this is only for test, we don’t have to store it in the metadata. If the testing tool can get the did file elsewhere, it should fine, right?

1 Like

Well we’re testing real canisters as close to production as possible, so the purpose is to test under normal conditions. We don’t want to create custom workarounds to get the test to pass, that defeats the purpose of the test.

We’re using dfx and a local replica, these are end-to-end/integration tests.

Okay, but real canisters probably won’t have a 400k did file. Anyway, the metadata limit is 1M, so you are probably storing something else as well?