Skip to content

Plugin lifecycle

Plugins are activated only after their manifest passes preflight.

  • onload() runs when the plugin activates.
  • onunload() runs when the plugin is disabled, fails rollback, or the vault closes.

Register resources in onload() and release them in onunload(). This includes commands, event listeners, timers, views, CSS, and long-running tasks.

Prefer registration helpers that return disposables or register cleanup automatically. If a plugin starts an interval, subscribes to an event, mounts a view, or creates a background task, keep the cleanup handle and dispose it during onunload().

module.exports = class ClockPlugin {
async onload() {
this.interval = window.setInterval(() => {
this.app.notices.show("tick");
}, 60_000);
}
async onunload() {
window.clearInterval(this.interval);
}
};

If activation throws, the plugin is marked failed and Lapis keeps workspace boot moving. Diagnostics should explain the failing plugin id, runtime host, and last error.