Repository navigation
fix(reports): stop reports crashing or hanging when Chromium closes - #48
Conversation
Code review
The reports handler now races Lighthouse against browser-context closure and a 120-second audit deadline, then cleans up the timer and context. The server also logs unhandled promise rejections so Lighthouse event-listener failures do not take down the process. Latest changes: The newest commits add browser-close and timeout promises around Lighthouse, returning through the existing error handling when either wins the race. Fix with agent prompt### Issue 1
src/server.ts:13-15
**Add a regression test for process-level rejection recovery**
Could we add a regression test that causes a CDP rejection during an active report and then verifies the server still handles a subsequent request? The existing browser recovery test kills Chromium before a screenshot, so it does not reliably exercise the unhandled-rejection behavior added here.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Walkthrough (2)
Still open from earlier reviews (1)
Reviewed the commits since Tip Comment |
| process.on("unhandledRejection", (reason) => { | ||
| console.error("Unhandled rejection:", reason); | ||
| }); |
There was a problem hiding this comment.
Add a regression test for process-level rejection recovery
Could we add a regression test that causes a CDP rejection during an active report and then verifies the server still handles a subsequent request? The existing browser recovery test kills Chromium before a screenshot, so it does not reliably exercise the unhandled-rejection behavior added here.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/server.ts
Line: 13-15
Comment:
**Add a regression test for process-level rejection recovery**
Could we add a regression test that causes a CDP rejection during an active report and then verifies the server still handles a subsequent request? The existing browser recovery test kills Chromium before a screenshot, so it does not reliably exercise the unhandled-rejection behavior added here.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.🟡 Minor · testing · Reply if this doesn't apply.
Docker Image Stats
Screenshot benchmark: Average of 3 runs on https://appwrite.io |

What changed
Lighthouse sends CDP commands from event listeners nothing awaits. When Chromium closes during a report (a memory budget restart since 0.3.16, or a crash), those commands reject outside any request and Bun exits, taking every capture in flight with it. Depending on when Chromium closes, Lighthouse can also never settle, so the request hangs until the caller gives up.
Tested
bun run lint,bun run check,bun run type-checkProtocol error (Runtime.evaluate): Session closed); with only the rejection handler, reports killed at 11 s and 13 s hung past the 90 s client timeout.