Skip to content

Commit

Permalink
fix: rate limit detection (#108)
Browse files Browse the repository at this point in the history
`body` is not null. In my experience I got:

```json
body: '{"data":{"rateLimit":{"cost":1,"remaining":0,"resetAt":"2019-08-05T12:01:30Z"},"node":{"comments":{"pageInfo":{"endCursor"...
```

I'm not certain why it would need to be `null` and why inspection of the header wouldn't suffice.

`statusCode` check is also unnecessary, `queryRequest` rejects for non-200 responses so `rateLimited` will not be called in this case.
  • Loading branch information
Alan Shaw authored and RichardLitt committed Sep 10, 2019
1 parent d2cfd94 commit b5ce577
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,8 @@ const abusive = e => {
}

const rateLimited = e => {
const body = JSON.parse(e.body)
const rem = e && e.headers && e.headers['x-ratelimit-remaining']
return e.status === 200 && body.data === null && rem && parseInt(rem) === 0
return rem && parseInt(rem) === 0
}

const untilReset = e => {
Expand Down

0 comments on commit b5ce577

Please sign in to comment.