Steps & Workflows

Steps are fundamental building blocks of Inngest, turning your Inngest Functions into reliable worflows that can runs for months and recover from failures.

Once you are familiar with Steps, start adding new capabilities to your Inngest Functions:

How Steps works?

You might wonder: how do Steps work? Why doesn't an Inngest Function get timed out when running on a Serverless environment?

You can think of steps as an API for expressing checkpoints in your workflow, such as waits or work that might benefit from retries or parallelism:

inngest.createFunction(
  { id: "sync-systems" },
  { event: "auto/sync.request" },
  async ({ step }) => {
    // By wrapping code in step.run, the code will be retried if it throws an error and when successfuly.
    // It's result is saved to prevent unnecessary re-execution
    const data = await step.run("get-data", async () => {
      return getDataFromExternalSource();
    });

    // Can also be retried up to 4 times
    await step.run("save-data", async () => {
      return db.syncs.insertOne(data);
    });
  },
);

Each step execution relies on a communication with Inngest's Durable Execution Engine which is responsible to:

  • Invoking Functions with the correct steps state (current step + previous steps data)
  • Gather each step result and schedule the next step to perform
Each Inngest Functions's step invocation implies a communication between your application and the Inngest Platform. The illustration shows how each step results in two requests to the deployed application.

This architecture powers the durability of Inngest Functions with retriable steps and waits from hours to months. Also, when used in a serverless environment, steps benefit from an extended max duration, enabling workflows that both span over months and run for more than 5 minutes!

Explore the following guide for a step-by-step overview of a complete workflow run:

SDK References