mixpanel / mixpanel-node

A node.js API for mixpanel
http://www.mixpanel.com
MIT License
477 stars 159 forks source link

Got Error: socket hang up #226

Open akshitkrnagpal opened 1 year ago

akshitkrnagpal commented 1 year ago

Hi

We have recently integrated mixpanel-node to send serverside events. Most of the events are being recorded but once in a while we get the following error and the event is NOT recorded.

ERROR   /node_modules/mixpanel/lib/mixpanel-node.js:156 mixpanel        Got Error: socket hang up

We would like some guidance to make sure we are sending all events without any data loss.

AksAman commented 11 months ago

This mainly happens in serverless functions due to the calling route closing before completing the request to mixpanel.

As mentioned in (https://github.com/mixpanel/mixpanel-node/issues/175#issuecomment-1497162831), Wrapping the tracking code with a promise solved this issue for me.