# Canister stuck with StackOverflow error, failing to deploy the fix

**URL:** <https://forum.dfinity.org/t/canister-stuck-with-stackoverflow-error-failing-to-deploy-the-fix/41046>\
**Category:** Developers\
**Created:** [February 10, 2025, 4:46pm UTC](https://forum.dfinity.org/t/canister-stuck-with-stackoverflow-error-failing-to-deploy-the-fix/41046 "2025-02-10T16:46:04Z")\
**Posts on this page:** 1\
**Page:** 1

<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 10, 2025, 4:46pm UTC](https://forum.dfinity.org/t/canister-stuck-with-stackoverflow-error-failing-to-deploy-the-fix/41046/1 "2025-02-10T16:46:04Z")

</div>

Anyone know how to fix this error:

`InternalError: "IC0502: Error from canister mjjyq-5yaaa-aaaag-atsnq-cai: Canister trapped: stack overflow. Consider gracefully handling failures from this canister or altering the canister to handle exceptions. See documentation`

On this motoko custom implementation of icrc1 [here](https://github.com/sonicdex/icrc-1-public/blob/main/src/token/main.mo) from Sonic.

How best can I fix this without loosing state?

It’s even failing to deploy anything, i’m trying to deploy a fix.

I have also tried increasing wasm limit, still giving same error
