andrewhughes101 / dependents-testing

Apache License 2.0
0 stars 0 forks source link

`RequestError [HttpError]: Bad credentials` #1

Open ljharb opened 4 years ago

ljharb commented 4 years ago

npx https://github.com/andrewhughes101/dependents-testing es-abstract 10 forks prints out a bunch of errors, and then spits out a bunch of data (not JSON):

Dependant {
  name: 'deep-equal',
  weeklyDownloads: 10404278,
  forks: 'undefined',
  stars: 'undefined',
  watchers: 'undefined'
}
Dependant {
  name: 'util.promisify',
  weeklyDownloads: 11071664,
  forks: 'undefined',
  stars: 'undefined',
  watchers: 'undefined'
}
Dependant {
  name: 'object.values',
  weeklyDownloads: 8583399,
  forks: 'undefined',
  stars: 'undefined',
  watchers: 'undefined'
}
Dependant {
  name: 'object.entries',
  weeklyDownloads: 6529373,
  forks: 'undefined',
  stars: 'undefined',
  watchers: 'undefined'
}
Dependant {
  name: 'array-includes',
  weeklyDownloads: 7081656,
  forks: 'undefined',
  stars: 'undefined',
  watchers: 'undefined'
}
Dependant {
  name: 'promise.prototype.finally',
  weeklyDownloads: 1816944,
  forks: 'undefined',
  stars: 'undefined',
  watchers: 'undefined'
}
Dependant {
  name: 'string.prototype.padstart',
  weeklyDownloads: 1827391,
  forks: 'undefined',
  stars: 'undefined',
  watchers: 'undefined'
}
Dependant {
  name: 'array.prototype.find',
  weeklyDownloads: 2406642,
  forks: 'undefined',
  stars: 'undefined',
  watchers: 'undefined'
}
Dependant {
  name: 'object.getownpropertydescriptors',
  weeklyDownloads: 11001113,
  forks: 'undefined',
  stars: 'undefined',
  watchers: 'undefined'
}
Dependant {
  name: 'string.prototype.padend',
  weeklyDownloads: 2692301,
  forks: 'undefined',
  stars: 'undefined',
  watchers: 'undefined'
}

Is there something I'm missing?

andrewhughes101 commented 4 years ago

@ljharb Sorry about that, forget to add a note or do a check for a github api token. I've fixed it up now and the dependents should be outputted in JSON now. PTAL

ljharb commented 4 years ago

Thanks; when I set that token, now I get:

Getting first 10 dependents of es-abstract sorted by forks
There are a total of 94 dependents
(node:95662) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined
    at Object.getRepoData ($HOME/.npm/_npx/95662/lib/node_modules/dependents-testing/lib/github.js:35:20)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:95662) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:95662) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
andrewhughes101 commented 4 years ago

I can't reproduce what your seeing, but I've updated the code to fix the problem I think your seeing PTAL

ljharb commented 4 years ago

Same credentials error (the length crash is fixed). What permissions does the token need to have? Most tokens should have repo read access, I'd think.

andrewhughes101 commented 4 years ago

The token should just need public repo access I think.

Just tried it with a token with no additional scope permissions and it works for me 😕

ljharb commented 4 years ago

Then it's likely not the token. Is there any more debug logging that can be done (currently it's just an unhandled promise rejection)? Happy to test a branch, as well.

andrewhughes101 commented 4 years ago

Ive pushed a commit to log the error before throwing but I think thats the best I can do at the moment

ljharb commented 4 years ago

Hmm, I guess it was a bad token; I used a different one and it's sort of working.

It seems like github's deps api doesn't allow you to only get direct deps? i'm mostly interested in testing things that directly depend on me.

andrewhughes101 commented 4 years ago

The tool just grabs all the deps from this page https://www.npmjs.com/browse/depended/es-abstract

Its not ideal, and I know there's an issue thats been raised in package maintenance to see if there is or can be other ways of doing this https://github.com/nodejs/package-maintenance/issues/331