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

Handle Rollbar API 50x errors, had a 502 Bad Gateway and didn't fail gracefully #1092

Open
saxaathlete opened this issue Jan 17, 2023 · 0 comments

Comments

@saxaathlete
Copy link

saxaathlete commented Jan 17, 2023

Hi there,

Sometimes Rollbar API has difficulties and throws 502 or 500 errors but instead of JSON the response is html:

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.17.9</center>
</body>
</html>

This type of response isn't handled and is failing when response is being parsed:

INTERNAL_ROLLBAR_ERROR SyntaxError: Unexpected token < in JSON at position 0
at Object.parse (<anonymous>)
at Object.jsonParse (/node_modules/rollbar/src/utility.js:356:25)
at _parseApiResponse (/node_modules/rollbar/src/server/transport.js:145:22)
at IncomingMessage.<anonymous> (/node_modules/rollbar/src/server/transport.js:120:5)

with new SyntaxError("JSON");:

726        if (state !== "ok" || (/[^\u0020\t\n\r]/.test(source))) {
727          throw (state instanceof SyntaxError)
728            ? state
729            : new SyntaxError("JSON");
729        }
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

1 participant