HubSpot / hubspot-api-nodejs

HubSpot API NodeJS Client Libraries for V3 version of the API
Apache License 2.0
322 stars 104 forks source link

What are the best limiter settings for TEN_SECONDLY_ROLLING #416

Open misha-erm opened 1 year ago

misha-erm commented 1 year ago

Hello,

This is more a discussion rather than an issue. Recently I saw that retry- and limiter- options were added to hubspot sdk and tried to use them.

Here is the code I used to get hubspot client:

import {Client} from '@hubspot/api-client';
import {LRUCache} from 'lru-cache';

const clientsPerToken = new LRUCache<string, Client>({
  max: 500,
});

export const getHubspotClient = (token?: string) => {
  if (!token) return new Client();

  let client = clientsPerToken.get(token);

  if (!client) {
    client = new Client({
      accessToken: token,
      limiterOptions: {
        reservoir: 99,
        reservoirRefreshAmount: 99,
        reservoirRefreshInterval: 10000,
      },
      numberOfApiCallRetries: 3,
    });

    clientsPerToken.set(token, client);
  }

  return client;
};

As I understand, limits are specific per customer/access token, that's why I setup new client for each user. Unfortunately this didn't help at all and I still see a lot of TEN_SECONDLY_ROLLING errors

Am I doing something wrong and are there any tips on how to debug it further? Thank you in advance

UPDATE: also tried DEFAULT_LIMITER_OPTIONS but it doesn't seem to do anything

ksvirkou-hubspot commented 11 months ago

HI @MikeYermolayev Limits are specific per access token (Private App)/account.

Per 10 seconds: 100 / private app Per day: 250,000 / account More info here

ksvirkou-hubspot commented 11 months ago

Are you create only an instance of client or a few instances of client for the same access token (private app)?

misha-erm commented 11 months ago

I create an instance of client per OAuth token