Skip to main content

Function configuration

Every option Inngest's createFunction() takes — except the triggers, which the transport decides, and onFailure, which has no Nest handler to call — can be set for every function, or for one.

For one pattern​

As the second argument of @InngestEventPattern:

@InngestEventPattern('orders.paid', {
id: 'charge-order',
retries: 2,
concurrency: { limit: 1, key: 'event.data.customerId' },
timeouts: { finish: '5m' },
})
charge(@Payload() order: Order) {}

or, with Nest's own decorator, in its extras under inngest:

@EventPattern<string>('orders.paid', {
inngest: { id: 'charge-order', retries: 2 },
} satisfies InngestPatternExtras)

For every function​

new InngestStrategy({
inngest,
httpAdapter,
retries: 5,
functionConfig: { timeouts: { start: '1m' } },
});

or as a function of the pattern:

functionConfig: (pattern) =>
pattern.startsWith('billing.') ? { concurrency: { limit: 1 } } : undefined,

Precedence​

From weakest to strongest:

  1. the defaults — id derived from the pattern, name: 'Handle <pattern>';
  2. the strategy's retries;
  3. the strategy's functionConfig;
  4. the pattern's own — @InngestEventPattern(pattern, config).

Each layer is merged over the one before, key by key.

What is available​

The full list is Inngest's function configuration. The ones you will reach for most:

optionfor
retriesattempts after the first, 0–20 (default 4)
concurrencyat most N runs at once, optionally per key (event.data.customerId)
throttle, rateLimitat most N runs per period — queued, or dropped
debouncewait for a quiet period and run once with the last event
idempotencyat most one run per key in 24 hours
priorityrun some events ahead of others
timeoutscancel a run that waits too long to start or takes too long to finish
cancelOncancel a run when another event arrives
batchEventsone run for many events — read them with context.getEvents()

:::note Batches

With batchEvents, @Payload() is the first event's data and context.getEvent() the first event; every event of the batch is context.getEvents().

:::