Closed 0xMrNight closed 3 years ago
@Richienb it looks like there's an exception being thrown and heroku is then not getting anything on the response
stream so it hangs/timesout:
2021-07-16T11:53:24.837863+00:00 app[web.1]: (node:33) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'license' of undefined
2021-07-16T11:53:24.837895+00:00 app[web.1]: at getRoute (file:///app/routes/get.js:77:44)
2021-07-16T11:53:24.837910+00:00 app[web.1]: (node:33) 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: 447)
I suspect it'll be easy to replicate with @mrnightdev's mit user.json file to find and deploy the fix - I'll take a look when I have moment after work too if you don't have time.
Quickly looking, I bet this is returning undefined https://github.com/remy/mit-license/blob/master/routes/get.js#L73
The error occurs because the site has not yet recognised the new user. When this happens, the function that reads user files throws an ENOENT
which passes through the error handler as intended and returns undefined
:
The problem happens when the code tries to load the fallback. In JavaScript, you can't access a property of undefined
and because user
is undefined
, the code throws before it can get to the fallback, 'MIT'
:
https://github.com/remy/mit-license/blob/94fa91d553b9eb46816d2a0a80f7fe0d7e1d11ce/routes/get.js#L77
The fix is to move the fallback values...
...into the conveniently labelled object that already exists:
Then it just needs to be returned instead when an ENOENT
error is thrown.
Thanks @Richienb 👍
I did check the file was in the users directory already - is there some timing that means it doesn't go across to the heroku instance?
Thank you @remy @Richienb for your timely help 😃
Hi, I created my page (7b39ab2b0fd89a31dde3786e377d040a1e31845b) around 2 days ago using the generator, but it doesn't seem to working. When I visit the page, all I get is this error:
For some reason I am getting the same error for all the users from
leodev
tocatfish
.I recall it working for an hour or so after generating the page, but not later that day.
Can I know how to fix this?