maven icon indicating copy to clipboard operation
maven copied to clipboard

Write partial build-report.json via shutdown hook on crash

Open gnodet opened this issue 1 month ago • 2 comments

Problem

build-report.json is only written at session end via BuildReportCollector.onSessionEnded(). If the build crashes (OOM, kill -9, uncaught exception that bypasses EventSpy), the report is lost — including all the diagnostic and timing data collected up to that point.

Proposed fix

Register a JVM shutdown hook in BuildReportCollector that writes a partial report with whatever data has been collected so far. The report should include a "status": "CRASHED" or "partial": true field so consumers know it's incomplete.

The normal onSessionEnded() path should deregister the shutdown hook to avoid double-writing.

Note: kill -9 cannot be intercepted by shutdown hooks. This covers OOM, normal signals, and uncaught exceptions.

Priority

Low — nice-to-have resilience improvement. The normal path works fine.

Related

  • #12695 — Build report PR
  • #12571 — Build output overhaul tracking issue

🤖 Drafted with Claude Code (Claude Opus 4.6). Reviewed and confirmed by @gnodet before submission.

gnodet avatar Oct 16 '26 09:10 gnodet

Hi Guillaume,

I'd like to contribute an implementation for this enhancement.

I noticed that PR #12695 is still open on "feature/build-report", which is part of the stacked build-output overhaul. Would you prefer that I prepare a follow-up patch against "feature/build-report" now, or wait until the stack is merged into "master" and submit an independent PR?

I want to ensure the contribution fits your planned direction and avoids conflicts with the ongoing work.

Thanks!

harshab054 avatar Oct 18 '26 14:10 harshab054

Hi, I've implemented a shutdown hook to write a partial build report when Maven terminates unexpectedly before the build session completes. The implementation reuses the existing report collection and persistence logic. Thank you.

codewithsinchana avatar Nov 11 '26 10:11 codewithsinchana