amplitude / Amplitude-Node

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

UnhandledRejection when amplitude server is unavailable #154

Closed tdimdimich closed 2 years ago

tdimdimich commented 2 years ago

When the server is unavailable (no internet connection for example) the logEvent throws an unhandled rejection

Expected Behavior

Do not throws an unhandled rejection

Current Behavior

Throws an unhandled rejection

Possible Solution

Catch node errors in line

Steps to Reproduce

  1. Disconnect your internet connection or set the serverUrl config to any non-existent address
  2. Call logEvent

Environment

Example error

unhandledRejection Error: getaddrinfo ENOTFOUND api2.amplitude.com
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:69:26) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'api2.amplitude.com'
}