Debounce functions v3.1.0+
Debounce delays a function run for the given period
, and reschedules functions for the given period
any time new events are received while the debounce is active. The function run starts after the specified period
passes and no new events have been received. Functions use the last event as their input data.
See the Debounce guide for more information about how this feature works.
export default inngest.createFunction(
{
id: "handle-webhook",
debounce: {
key: "event.data.account_id",
period: "5m",
},
},
{ event: "intercom/company.updated" },
async ({ event, step }) => {
// This function will only be scheduled 5m after events have stopped being received with the same
// `event.data.account_id` field.
//
// `event` will be the last event in the series received.
}
);
- Name
debounce
- Type
- object
- Required
- optional
- Description
Options to configure how to debounce function execution
Properties- Name
period
- Type
- string
- Required
- required
- Description
The time delay to delay execution. The period begins when the first matching event is received.
Current permitted values are from
1s
to7d
(168h
).
- Name
key
- Type
- string
- Required
- optional
- Description
An optional unique key expression to apply the limit to. The expression is evaluated for each triggering event, and allows you to debounce against event data.
Expressions are defined using the Common Expression Language (CEL) with the original event accessible using dot-notation. Read our guide to writing expressions for more info. Examples:
- Rate limit per customer id:
'event.data.customer_id'
- Rate limit per account and email address:
'event.data.account_id + "-" + event.user.email'
- Rate limit per customer id:
- Name
timeout
- Type
- string
- Required
- optional
- Description
The maximum time that a debounce can be extended before running.
Functions will run using the last event received as the input data.
Debounce cannot be combined with batching.