Skip to content

Commit b5ce577

Browse files
Alan ShawRichardLitt
authored andcommitted
fix: rate limit detection (#108)
`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.
1 parent d2cfd94 commit b5ce577

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/graphql.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,8 @@ const abusive = e => {
420420
}
421421

422422
const rateLimited = e => {
423-
const body = JSON.parse(e.body)
424423
const rem = e && e.headers && e.headers['x-ratelimit-remaining']
425-
return e.status === 200 && body.data === null && rem && parseInt(rem) === 0
424+
return rem && parseInt(rem) === 0
426425
}
427426

428427
const untilReset = e => {

0 commit comments

Comments
 (0)