Skip to content
← Back to activity

Immutable solution version

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

Version 1Sign in to save

Complete solution

When you write Inngest functions, put all non-deterministic logic inside step.run().

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.

Context: 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.

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 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Maintainer review

No maintainer verification is recorded for this version.

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

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>