egoist / gh-pinned-repos

API service for retrieving pinned repos on GitHub.
https://gh-pinned-repos.egoist.dev
MIT License
116 stars 17 forks source link

Server fails when use the https://gh-pinned-repos.egoist.sh/ #9

Closed joseluisgs closed 3 years ago

joseluisgs commented 3 years ago

Hi

O have his response when I use: https://gh-pinned-repos.egoist.sh/?username=joseluisgs

This Serverless Function has crashed.

Your connection is working correctly.

Vercel is working correctly.

500: INTERNAL_SERVER_ERROR Code: FUNCTION_INVOCATION_FAILED ID: cdg1::7znmw-1628181658492-353979fee031

If you are a visitor, contact the website owner or try again later. If you are the owner, learn how to fix the error and check the logs.

joseluisgs commented 3 years ago

Ok, the fails is here: const languageColor = $(item) .find('.repo-language-color') .css( "background-color" );

Due to: TypeError: Cannot read property 'attribs' of undefined at getCss (/Users/link/Proyectos/gh-pinned-repos/node_modules/cheerio/lib/api/css.js:66:25) at initialize.exports.css (/Users/link/Proyectos/gh-pinned-repos/node_modules/cheerio/lib/api/css.js:22:12) at Object. (/Users/link/Proyectos/gh-pinned-repos/index.js:34:10) at initialize.exports.each (/Users/link/Proyectos/gh-pinned-repos/node_modules/cheerio/lib/api/traversing.js:294:24) at /Users/link/Proyectos/gh-pinned-repos/index.js:17:12 at processTicksAndRejections (internal/process/task_queues.js:95:5) at async module.exports (/Users/link/Proyectos/gh-pinned-repos/index.js:95:14)

I think the problem is due to background color.

I remove language color and everything is ok!!!

joseluisgs commented 3 years ago

Sometimes there is some projects that GitHub can't detect. I think is better insert try catch options.

joseluisgs commented 3 years ago

There is 2 solutions: 1, in the projects without elemento, add in .gitattributes, for exampel language.

  1. I make a pull request with try catch to check it and refactor the code if someday any property or css change https://github.com/egoist/gh-pinned-repos/pull/10