Skip to content

Trap JSON parse errors properly #32

Description

@GeoffreyPlitt

JSON parsing sometimes fails due to malformed input, and the promise is corrupted (stack dump to console log)

Instead, should capture this in promise-reject for proper promise chain handling.

Example:

SyntaxError: Unexpected token e in JSON at position 2
    at JSON.parse (<anonymous>)
    at MixpanelExport._parseResponse (/app/node_modules/mixpanel-data-export/src/mixpanel_data_export.js:180:17)
    at exports.XMLHttpRequest.request.onload (/app/node_modules/mixpanel-data-export/src/mixpanel_data_export.js:151:21)
    at exports.XMLHttpRequest.dispatchEvent (/app/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
    at setState (/app/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:614:14)
    at IncomingMessage.<anonymous> (/app/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:447:13)
    at IncomingMessage.emit (events.js:194:15)
    at IncomingMessage.EventEmitter.emit (domain.js:441:20)
    at endReadableNT (_stream_readable.js:1125:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions