Runtimes
Web triggers
Async functions
Product REST APIs
Fetch APIs

Error handling for Forge async events

The @forge/events package exports asynchronous event errors. The following example shows how the package handles rate limit errors:

1
2
import { RateLimitError } from '@forge/events';

try {
  const queue = new Queue({ key: "queue-name"});
  queue.push(["/* payload for this event */"]);
} catch (error) {
  if (error instanceof RateLimitError) {
	// Handle rate limit error
  }
}
Error typeDescription
PartialSuccessErrorSome pushed events were not recorded for later processing. Each event can have a different reason for failure. To get error details for failed events, inspect the errors failedEvents property here.
RateLimitErrorThe total number of events pushed per minute exceeds the defined limits. To overcome this, retry adding events after a minute.
TooManyEventsErrorMore than 50 events were pushed to the queue in a single request. See Async events limits for more details about this limit.
PayloadTooBigErrorThe combined payload of events pushed in a single request exceeded 200kb. See Async events limits for more details about this limit.
InvalidQueueNameErrorThe queue name is invalid. A valid queue name is alphanumric string, and can starts with _.
InvocationLimitReachedErrorAn event resolver can push more events to the queue, creating a cycle. This error means an event pushed another event into the queue more than 1000 times. To avoid this, process more events in parallel. See Async events limits for more details about this limit.

Example of how to inspect the errors in the failedEvents property:

1
2
try {
	await queue.push([/* payload of the events */]);
} catch (error) {
  if (error instanceof PartialSuccessError) {
	  const failedEvents = error.failedEvents;
    }
}

Rate this page: