Long running actions
By default, an action is terminated when the person running the action leaves the page.
While we think this is a solid default, it isn't a desirable behavior when creating long running actions like batch migration tools.
To solve for this, Interval allows you to mark an action as backgroundable, meaning it continues running even when you leave the page.
- TypeScript
- JavaScript
In code, you can specify backgroundable: true
when defining your action:
import { Action } from "@interval/sdk";
export default new Action({
backgroundable: true,
handler: async () => {
// action logic here
},
});
In code, you can specify backgroundable: true
when defining your action:
const { Action } = require("@interval/sdk");
module.exports = new Action({
backgroundable: true,
handler: async () => {
// action logic here
},
});
When an action is running the background, the person running it will automatically receive a notification when it completes or requires input.
Backgroundability makes Interval a powerful tool for writing resilient code. For example, instead of erroring on an unexpected condition in a long running job, you can easily prompt for user intervention.