Skip to content

Import batch does not handle rate limiting #231

@BjornTheProgrammer

Description

@BjornTheProgrammer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions