JavaScript Rate Limiting Handling Library

Hello developers,

I recently created a JavaScript library to handle REST API rate limiting. The code is open source and available at GitHub - dugaldmorrow/handle-rate-limiting-js.

The library is oriented to handling Jira and Confluence REST API rate limiting “out of the box” and can be configured for different kinds of execution contexts. It uses the built in fetch implementation and types provided by Node 18, but also allows different types of behaviour to be injected.

I hope this is useful for those who are still starting out on their journey for handling rate limiting. As a reminder, here are the Jira and Confluence rate limiting guides:

Regards,
Dugald

3 Likes

Thanks @dmorrow , looking forward to try!

1 Like

Thanks @dmorrow but how does this implement rate limiting per cost-budget? This looks like per-request rate limiting, not per cost-budget rate limiting?

If this was used in an application that made requests using user-impersonation then it would need to keep track of which users had been rate limited and act as a circuit breaker for subsequent requests no?

1 Like

Hi @jbevan , you raise a good point. The library doesn’t take into account Jira’s cost budget rate limiting logic. This means, each REST API request is managed in isolation from other requests. The Retry-After header values returned by Jira would reflect the cost budgets, but the library makes no attempt to track this so, for example, it would blindly send an API request even though requests against the same cost budget were being rate limited in other threads. It would probably be feasible to enhance the library optionally consider cost budget tracking.

Regards,
Dugald

1 Like