Storage and timers
novon.kv for persistence across reloads, and the timer functions inside the sandbox.
Key / value storage
Requires the kv permission. Storage is per config entry and survives reloads, reboots and bundle
updates.
const seen = novon.kv.get<string[]>('seenIds') ?? [];
novon.kv.set('seenIds', [...seen, id]);
novon.kv.delete('seenIds');Values are JSON, at most 64 KiB each. Use it for discovery caches, tokens you refreshed, and last-known values you want to restore before the first poll completes. It is synchronous.
Timers
Requires the timers permission. setTimeout, setInterval, clearTimeout and clearInterval
behave as in the browser, with limits: 64 live timers per entry, intervals of at least one second.
The hub clears all timers when the entry unloads.
let poll: number | undefined;
async setupEntry(ctx) {
poll = setInterval(() => refresh(ctx), Number(ctx.entry.options.pollSeconds ?? 30) * 1000);
}
unloadEntry() {
clearInterval(poll); // optional: the hub does this for you
}novon.sleep(ms) is a promise-based pause for sequencing requests.
CPU budget
Each entry has a CPU budget in addition to the 32 MB heap. Busy loops and heavy parsing on every
poll will exhaust it; parse once, cache in kv, and keep intervals reasonable. Exceeding the budget
stops the entry and marks it failed with the reason.