Pre_upgrade hook failed, what to do?

Canister violated contract: "ic0_call_new" cannot be executed in pre upgrade mode.

I changed pre_upgrade back, but it is still stuck :cry:
Is there any solution?

I see the following options:

  • if possible, try to prevent the code path invoking ic0.call_new from triggering
  • if the pre-upgrade hook is not strictly necessary (e.g., if all data is in stable memory anyway), the pre-upgrade hook can be skipped entirely using the --skip-pre-upgrade option of dfx canister install
  • if none of the above is possible, it might be possible to both skip the pre-upgrade hook and preserve the canister heap across an upgrade (using the --wasm-memory-persistence option of dfx canister install), but this option requires careful testing as it was originally intended for Motoko EOP, not for canisters written in generic-purpose high-level languages (moreover, the new canister WASM must also include a custom section called enhanced-orthogonal-persistence).