Skip to main content
When events fire in rapid succession, such as a user saving a document repeatedly, you often only want to perform a reaction (like syncing to an external API) once the activity stops. Instead of cancelling previous hooks (which requires tracking IDs), you can use a Stale Check pattern.

Workflow

  1. Schedule: On every event, schedule a hook for X minutes in the future. Pass the current timestamp.
  2. Verify: When the hook fires, compare the passed timestamp with the resource’s current updatedAt.
  3. Discard: If the resource is newer than the event, it means a subsequent event occurred. Discard this hook.

Example: Sync to Salesforce

Sync a user profile to Salesforce 5 minutes after their last edit.
This ensures that if a user updates their profile 10 times in one minute, only the last hook will actually trigger the sync. The previous 9 will detect they are “stale” and exit immediately.