-
Notifications
You must be signed in to change notification settings - Fork 116
Description
Canisters that are upgradeable with zero downtime are probably quite important for some uses cases, and while it seems not possible for code that uses await
, it might just be possible for canisters that only use one-way messages.
Luckily, Motoko was created when we thought we would have them on the system level, and so is Candid, so we know which shared method calls are meant to be fire-and-forget.
For these, instead of registering do-nothing callbacks, I suggest the following trick: We pass -1
as the table index for the callbacks. When the callback comes back, this will trap, but that is fine - the trap is just as good as the do-nothing callback. But the advantage is that it will do that reliably even after an upgrade (assuming no canister accepted by the system will ever have a table of size 2^32 ). So a developer who writes their canisters in the plain actor model, with only one-way calls, will be able to safely upgrade the canister, even with the current System API (i.e. no need to wait for changes to the system api).
Developers still need to manually figure out if stopping is needed or not, but at least it's one way foward, await from the current, quite unsatisfying "stop-it-first" regime.