DAEMON_EXPIRATION cicd runtime_error ai_generated true

org.gradle.launcher.daemon.server.DaemonExpirationPeriodicCheck: Daemon will be stopped at the end of the build after running for 3 hours and exceeding the 2-hour idle timeout.

ID: cicd/gradle-daemon-stopped-before-finish

Also available as: JSON · Markdown · 中文
82%Fix Rate
85%Confidence
1Evidence
2023-06-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Gradle 7.5 active
Gradle 8.0 active
Gradle 8.2 active

Root Cause

Gradle Daemon is configured with a low idle timeout (e.g., 2 hours) and the build runs longer than that, causing the daemon to be killed before the build completes, especially on long-running CI jobs.

generic

中文

Gradle守护进程配置了较低的闲置超时时间(例如2小时),而构建运行时间超过了该时间,导致守护进程在构建完成前被终止,尤其在长时间运行的CI任务中。

Official Documentation

https://docs.gradle.org/current/userguide/gradle_daemon.html

Workarounds

  1. 85% success Increase the daemon idle timeout in gradle.properties: org.gradle.daemon.idletimeout=7200000 (2 hours in milliseconds) or set it to 0 to disable idle timeout.
    Increase the daemon idle timeout in gradle.properties: org.gradle.daemon.idletimeout=7200000 (2 hours in milliseconds) or set it to 0 to disable idle timeout.
  2. 80% success Disable the Gradle Daemon for CI builds by adding --no-daemon to the Gradle command, forcing a new JVM for each build.
    Disable the Gradle Daemon for CI builds by adding --no-daemon to the Gradle command, forcing a new JVM for each build.
  3. 75% success Split the build into smaller, parallel tasks to reduce individual build time below the idle timeout threshold.
    Split the build into smaller, parallel tasks to reduce individual build time below the idle timeout threshold.

中文步骤

  1. Increase the daemon idle timeout in gradle.properties: org.gradle.daemon.idletimeout=7200000 (2 hours in milliseconds) or set it to 0 to disable idle timeout.
  2. Disable the Gradle Daemon for CI builds by adding --no-daemon to the Gradle command, forcing a new JVM for each build.
  3. Split the build into smaller, parallel tasks to reduce individual build time below the idle timeout threshold.

Dead Ends

Common approaches that don't work:

  1. 75% fail

    The daemon idle timeout is a Gradle configuration parameter, not a cache or runner issue.

  2. 80% fail

    Heap size affects memory, not the daemon's idle timeout behavior.

  3. 70% fail

    The timeout is set in gradle.properties or via command line flags, not by installation.