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

Using promises #230

Open
shareefhadid opened this issue Mar 13, 2024 · 1 comment
Open

Using promises #230

shareefhadid opened this issue Mar 13, 2024 · 1 comment

Comments

@shareefhadid
Copy link

shareefhadid commented Mar 13, 2024

This package should really be using promises as most calls are asynchronous.

This wasn't made clear in the documentation, but I realized it when I performed an expensive operation and the connection closed before it could be completed.

For now I need to wrap the calls in promises myself and resolve/reject in the callback like so:

await new Promise((resolve, reject) => {
  mixpanel.people.set_once(identifier, data, (e) => {
    if (e) {
      reject(e);
    }

    resolve(null);
  });
}
@vsnthdev
Copy link

vsnthdev commented May 22, 2024

I was using this on Vercel Serverless functions, and events weren't reflecting on the dashboard. After doing some investigation, turns out the serverless function closes even before a request is fully made.

Thanks for the solution @shareefhadid

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

2 participants