How to upgrade a canister with hanging requests

I have a canister with hanging requests(self calls or inter canister calls).

Trying to upgrade:

canister_pre_upgrade attempted with outstanding message callbacks (try stopping the canister before upgrade)

Trying to stop canister gets stuck in stopping state.

Is there a way to force stop the canister?

IIRC if you uninstall all code outstanding call contexts are dropped, but that will drop all your data as well

1 Like

As far as I can see, this is a fairly common problem lately. In ICP, due to the novelty of the technology, there are quite a lot of “pitfalls” that strongly affect canisters. This again proves why it’s important to thoroughly audit all code before deploying to the main network. This saves not only time and money, but also shows in which direction it is better to move during development.

1 Like

It was possible to upgrade the canister by setting a large freezing threshold

1 Like

That is an interesting result. Does anyone have an explanation?

What is the functional difference between stopping and running but frozen?

Is the difference that if frozen then all responses trap? So it can break an infinite loop of downstream calls?

Responses are processed for either stopping or frozen canisters, no explicit traps.

The difference is that a canister that’s frozen will not make more outgoing calls. So in case where you have an infinite loop that keeps sending a new one whenever you process a response, it will break out of it.