Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import batch does not handle rate limiting #231

Open
BjornTheProgrammer opened this issue Mar 22, 2024 · 0 comments
Open

Import batch does not handle rate limiting #231

BjornTheProgrammer opened this issue Mar 22, 2024 · 0 comments

Comments

@BjornTheProgrammer
Copy link

The following code just console errors a bunch when running.

import Mixpanel from 'mixpanel';

const mixpanel = Mixpanel.init('1185e7d1999cbf30e66076c105b11c49', {
    secret: 'd8bb5e232b89a8b5adc88d500ac78106'
});

const events = [
    {
        event: 'Thing',
        properties: {
            ...
        }
    },
    ...
]

mixpanel.import_batch(events, (errs) => { // Events is very, very large
    console.error(errs);
})
      at /Users/bjorn/Desktop/project/node_modules/mixpanel/lib/mixpanel-node.js:147:42
      at endReadableNT (node:stream:2426:53)
, 142 |                     catch(ex) {
143 |                         e = new Error("Could not parse response from Mixpanel");
144 |                     }
145 |                 }
146 |                 else {
147 |                     e = (data !== '1') ? new Error("Mixpanel Server Error: " + data) : undefined;
                                               ^
error: Mixpanel Server Error: {"error":"Project exceeded rate limits. Please retry the request with exponential backoff.","status":0}

Seems to me that the library should handle the issue of rate limiting, instead of the end user. Discord.js is an example of this. It's library handles potential rate limiting issues. Please consider adding this as a feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant