foo-software / lighthouse-persist

Uploads a Lighthouse report to your AWS S3 account.
12 stars 3 forks source link

Missing catch causes infinite github action #1

Closed schoenwaldnils closed 4 years ago

schoenwaldnils commented 4 years ago

Hi there

I had a problem with the Github action for the lighthouse-check. I set the outputDirectory to a custom path. But since this directory did not exists as the check ran it caused the Github action to crash. Well .. it didn't. It got stuck. (one test ran for about an hour before I stopped it)

Interestingly right at that point, Github actions started to get errors: https://www.githubstatus.com/incidents/2k3z9fkr9z5g I don't know if I caused it 🤔

When I stopped the run I got this error:

Error: ENOENT: no such file or directory, open '/lighthouse/lighthouse-report-1586846070284.html'
    at Object.openSync (fs.js:440:3)
    at Object.writeFileSync (fs.js:1265:35)
    at _default (/home/runner/work/_actions/foo-software/lighthouse-check-action/master/node_modules/@foo-software/lighthouse-persist/dist/index.js:87:17)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async localLighthouse (/home/runner/work/_actions/foo-software/lighthouse-check-action/master/node_modules/@foo-software/lighthouse-check/dist/localLighthouse.js:75:7)
    at async _default (/home/runner/work/_actions/foo-software/lighthouse-check-action/master/node_modules/@foo-software/lighthouse-check/dist/localLighthouse.js:125:35)
    at async /home/runner/work/_actions/foo-software/lighthouse-check-action/master/node_modules/@foo-software/lighthouse-check/dist/lighthouseCheck.js:159:32 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/lighthouse/lighthouse-report-1586846070284.html'
}

The run: https://github.com/schoenwaldnils/timeline/pull/50/checks?check_run_id=584819910

And that's why I'm here. The missing try-catch here: https://github.com/foo-software/lighthouse-persist/blob/master/src/index.js#L77 caused an infinite Github action.

As I created the directory beforehand there was no problem.

adamhenson commented 4 years ago

Wow, that's an interesting one. Thanks for reporting it. Typically, I think it's a good idea to let errors bubble up from Node modules, however in this case it seems perhaps there is an issue when chrome.kill() isn't called? This is definitely worth investigating.

adamhenson commented 4 years ago

This issue is fixed from #2 🙌

I confirmed my theory was correct (described in the PR above). I was able to confirm the fix by 1st reproducing the issue by creating a GitHub Action run with a bad outputDirectory. I manually killed the test after 39 minutes... so it was a legitimate bug. With the fix, the GitHub Action run terminates immediately with the correct error message.

Before: Job Hangs (Infinitely?)

Screen Shot 2020-04-28 at 11 32 21 PM

After: Fails and Completes Immediately

Screen Shot 2020-04-28 at 11 32 03 PM

Once again, nice find @schoenwaldnils. Thanks for your help.

adamhenson commented 4 years ago

Released in lighthouse-check-action@1.0.12.