Skip to content

Error callback not firing when hitting rate limit #348

Closed
@divergentdave

Description

@divergentdave

I'm using github-api in Node v4.4.5, and I've found that if I exhaust the 60 request/hour unauthenticated rate limit, then certain functions never call their callback. For example, the following script works normally until I hit the limit, then after that the callback never gets called.

#!/usr/bin/env node
"use strict";
var GitHub = require("github-api");
var gh = new GitHub({});

var username = "divergentdave";
var user = gh.getUser(username);
user.listRepos(function(error, result, request) {
    console.log("hit callback");
    if (error) {
        console.error(error);
        return;
    }
});

pi@raspberrypi ~/github-user-branches $ node check-rate-limit.js 
Limit remaining: 1
Reset date: Mon Jun 13 2016 20:45:09 GMT-0500 (CDT)
pi@raspberrypi ~/github-user-branches $ node example.js 
hit callback
pi@raspberrypi ~/github-user-branches $ node example.js 
pi@raspberrypi ~/github-user-branches $ 

Other methods, such as User.getProfile() properly call the callback with an error object, complete with details of the 403 response from the API server. I haven't arrived at the root cause yet, but it is most likely in Requestable._requestAllPages.

I'd be up for working on a PR for this, but first, testing for this issue should probably be done with fixture data for the HTTP responses, rather than hitting the GitHub servers directly. Do you have any preferences for which mocking library to use? I see that nock is a popular choice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy