To make sure that I was not making an error, I created a new project and copied verbatim the code from the docs here: Heartbeats :: Internet Computer
That is, I have a single canister with code:
import Debug "mo:base/Debug";
actor Alarm {
let n = 5;
var count = 0;
public shared func ring() : async () {
Debug.print("Ring!");
};
system func heartbeat() : async () {
if (count % n == 0) {
await ring();
};
count += 1;
}
}
And I get the following error:
type error [M0129], unexpected system method named heartbeat, expected preupgrade or postupgrade.
Why am I getting this unexpected error?