Search code examples
gradlejitpack

gradle sporadically times out fetching jar from JitPack


My project builds with gradle and has some dependencies which are on JitPack. Occasionally, builds fail due to a timeout when fetching the jar from JitPack:

> Task :preDebugBuild FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':preDebugBuild'.
> Could not resolve all files for configuration ':debugCompileClasspath'.
   > Could not resolve org.traffxml:traff-eismoinfo-intensity:master-SNAPSHOT.
     Required by:
         project :
      > Could not resolve org.traffxml:traff-eismoinfo-intensity:master-SNAPSHOT.
         > Unable to load Maven meta-data from https://jitpack.io/org/traffxml/traff-eismoinfo-intensity/master-SNAPSHOT/maven-metadata.xml.
            > Could not HEAD 'https://jitpack.io/org/traffxml/traff-eismoinfo-intensity/master-SNAPSHOT/maven-metadata.xml'.
               > Read timed out

This seems to be a general issue with JitPack. When requesting a jar which is not in the cache yet, this obviously takes longer as JitPack has to build the jar first. However, in this case master-SNAPSHOT refers to a release which was already built a week ago, hence response time seems to be a general issue with JitPack. At the most, I could imagine this being related to snapshot releases, as JitPack would need to check for a new version each time—which might mean stable releases are not affected.

For a local build the timeout is a minor annoyance, as I’ll have to re-run the build a time or two, but in a CI pipeline, it will lead to sporadic failures and either lots of manual intervention or increased complexity for some “retry after timeout” logic.

What gives? Can I increase the timeout for gradle somewhere? Does JitPack behave differently on non-snapshot releases (so this issue might only be relevant to development builds, not to released versions which rely on stable versions, not snapshots)?


Solution

  • You can increase timeout by adding these to your gradle.properties

    systemProp.org.gradle.internal.http.connectionTimeout=180000
    systemProp.org.gradle.internal.http.socketTimeout=180000
    

    You might also be able to trigger a Jitpack build from your ci to increase the likelihood of the dependency being cached when you need it.