You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.
Octonode client.repo() method does return {"message":"Unexpected token <", ..... } when GitHub call hits the GitHub rate limit. This is somewhast misleading. It took me quite some time to figure I have a GitHub rate limit issue.
Here's a pseudo code sample showing how I ran into the issue ....
var ghrepo=client.repo(<orgname>+'/'+<reponame>);
ghrepo.info( function(err,info) {
if (err) {
/*
info contains the following message when GitHub rate limit is exceeded
{"message":"Unexpected token <", ..... }
Probable root cause is method Client.prototype.errorHandle(res,body,callback).
It tries to parse body in the GitHub response and expects it to be JSON format.
The response body in case GitHub rate limit is reached looks like the following:
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx</center>
</body>
</html>
This cause the JSON.parse(body ... ) to fail with 'Unexpected token >....' which is then returned to the caller of ghrepo.info() . Returning the 403 FORBIDDEN might be more appropriate.
*/
}
else {
}
}
The text was updated successfully, but these errors were encountered:
We should add a rate limit check after every response return for the client and before parsing it. Would you be willing to work on this?
pksunkara
changed the title
Misleading error {"message":"Unexpected token <" when GitHub returns HTTP 403 because of rate limit
Rate Limit check needed before parsing response body
Mar 3, 2017
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Octonode client.repo() method does return {"message":"Unexpected token <", ..... } when GitHub call hits the GitHub rate limit. This is somewhast misleading. It took me quite some time to figure I have a GitHub rate limit issue.
Here's a pseudo code sample showing how I ran into the issue ....
The text was updated successfully, but these errors were encountered: