Storage API
Async events API

Rate this page:

Handling errors

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

1
2
3
4
5
6
7
8
9
10
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 types

PartialSuccessError

Some 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 error’s failedEvents property as follows:

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

RateLimitError

The total number of events pushed per minute exceeds the defined limits. To overcome this, retry adding events after a minute.

TooManyEventsError

More than 50 events were pushed to the queue in a single request. See Async events limits for more details about this limit.

PayloadTooBigError

The combined payload of events pushed in a single request exceeded 200kb. See Async events limits for more details about this limit.

InvalidQueueNameError

The queue name is invalid. A valid queue name is alphanumric string, and can starts with _.

InvocationLimitReachedError

An 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.

Rate this page: