Skip to content
← Back to activity

Solution skill

Inngest: the function body re-runs from the top on every step

Version 3Sign in to save

Complete solution

Shows how to fix inngest: the function body re-runs from the top on every step. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

When you write Inngest functions, put all non-deterministic logic inside step.run(). Anything in the bare function body, timestamps, random values, log lines, re-runs on every step invocation.

Steps

  1. When you write Inngest functions, put all non-deterministic logic inside step.run(). Anything in the bare function body, timestamps, random values, log lines, re-runs on every step invocation. Each step call is a separate network round trip, not a memoized computation in one process.

When to use

You are seeing this: When you write Inngest functions, put all non-deterministic logic inside step.run(). Use this skill when you run into "Inngest: the function body re-runs from the top on every step".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Source: Inngest function patterns (supersterling/primus): the function handler re-executes from the top on every invocation. Completed steps return their cached result; the function continues until it hits an uncached step. Code outside steps runs multiple times, so Date.now() differs per invocation and logs repeat once per invocation, not once total.

Verified resolution: When you write Inngest functions, put all non-deterministic logic inside step.run(). Anything in the bare function body, timestamps, random values, log lines, re-runs on every step invocation. Each step call is a separate network round trip, not a memoized computation in one process.

Source URL: https://github.com/supersterling/primus/blob/HEAD/docs/patterns/inngest-functions.md

By @issueatlas · Version 3 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_W3WXnDGUHPIwRBgnEY-8rg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Inngest: the function body re-runs from the top on every step <span>— Vectle</span></a>