amplitude / Amplitude-Node

Server-side Node.js SDK for Amplitude
MIT License
67 stars 20 forks source link

Intermittent Unknown Errors #108

Closed calvinl closed 3 years ago

calvinl commented 3 years ago

Hello,

I've filed this report with the support team, but they recommended opening a ticket here as well. I got word that the node SDK is swallowing some errors, so I wanted to create a ticket here to track it. I am willing to help out with a PR if necessary also.

We have this running on a system with Google pubsub, so we are retrying messages when we receive this error. Our messages backlog eventually goes down to 0, so they appear to succeed on retry, but it would be helpful to understand what this error is.

Expected Behavior

When pushing events to Amplitude via client.logEvent(), it should return a meaningful error message.

Current Behavior

We are receiving a lot of errors like the following:

{
  "status":  "unknown",
  "statusCode": 0
}

Possible Solution

Unsure

Steps to Reproduce

import * as Amplitude from '@amplitude/node';

// amplitude client
const client = Amplitude.init(AMPLITUDE_API_KEY);

(async function () {
  // an array of events
  let events = [
    { event_type: 'app_did_launch', ...restEvent },
    { event_type: 'view_post', ...restEvent },
    ...restEvents
  ];

  // log each event
  events.forEach(client.logEvent);

  // flush events
  const response = await client.flush();

  console.log(response);  // occasionally, we will receive { status:  'unknown', statusCode: 0 }
})();

Environment

dantetam commented 3 years ago

Hello @calvinl ,

We're working on getting these specific error messages out ASAP.

Dante

calvinl commented 3 years ago

@dantetam I upgraded from 1.5.3 to 1.5.4 over the weekend, and the Unknown errors seem to have gone away. It may have been related to #101?

jooohhn commented 3 years ago

@calvinl #112 should have fixed this. The problem was that our event sending logic was swallowing Node system errors without passing it on to client.