xerial / sbt-sonatype

A sbt plugin for publishing Scala/Java projects to the Maven central.
Apache License 2.0
335 stars 65 forks source link

Timeout Exception in sbt-sonatype plugin causes release failure to Sonatype Central #518

Open j5ik2o opened 2 months ago

j5ik2o commented 2 months ago

Describe the bug The sbt-sonatype plugin is failing to release artifacts to Sonatype Central due to a timeout exception. The plugin does not properly handle sttp.client4.SttpClientException$TimeoutException, causing the release process to fail.

How to reproduce the issue

  1. Set up a project with sbt-sonatype plugin configured for release to Sonatype Central.
  2. Attempt to release artifacts using sbt -v ci-release.
  3. The process fails with a sttp.client4.SttpClientException$TimeoutException.
$ sbt
sbt:akka-persistence-dynamodb-root> sonatypeProfileName
[info] snapshot-base / sonatypeProfileName
[info]  io.github.j5ik2o
[info] state-v2 / sonatypeProfileName
[info]  io.github.j5ik2o
[info] snapshot-v2 / sonatypeProfileName
[info]  io.github.j5ik2o
[info] benchmark / sonatypeProfileName
[info]  io.github.j5ik2o
[info] example / sonatypeProfileName
[info]  io.github.j5ik2o
[info] test / sonatypeProfileName
[info]  io.github.j5ik2o
[info] base / sonatypeProfileName
[info]  io.github.j5ik2o
[info] snapshot-v1 / sonatypeProfileName
[info]  io.github.j5ik2o
[info] journal-v1 / sonatypeProfileName
[info]  io.github.j5ik2o
[info] journal-base / sonatypeProfileName
[info]  io.github.j5ik2o
[info] state-v1 / sonatypeProfileName
[info]  io.github.j5ik2o
[info] base-v1 / sonatypeProfileName
[info]  io.github.j5ik2o
[info] journal-v2 / sonatypeProfileName
[info]  io.github.j5ik2o
[info] state-base / sonatypeProfileName
[info]  io.github.j5ik2o
[info] base-v2 / sonatypeProfileName
[info]  io.github.j5ik2o
[info] sonatypeProfileName
[info]  io.github.j5ik2o

sbt:akka-persistence-dynamodb-root> sonatypeRepository
[info] snapshot-base / sonatypeRepository
[info]  https://central.sonatype.com/service/local
[info] state-v2 / sonatypeRepository
[info]  https://central.sonatype.com/service/local
[info] snapshot-v2 / sonatypeRepository
[info]  https://central.sonatype.com/service/local
[info] benchmark / sonatypeRepository
[info]  https://central.sonatype.com/service/local
[info] example / sonatypeRepository
[info]  https://central.sonatype.com/service/local
[info] test / sonatypeRepository
[info]  https://central.sonatype.com/service/local
[info] base / sonatypeRepository
[info]  https://central.sonatype.com/service/local
[info] snapshot-v1 / sonatypeRepository
[info]  https://central.sonatype.com/service/local
[info] journal-v1 / sonatypeRepository
[info]  https://central.sonatype.com/service/local
[info] journal-base / sonatypeRepository
[info]  https://central.sonatype.com/service/local
[info] state-v1 / sonatypeRepository
[info]  https://central.sonatype.com/service/local
[info] base-v1 / sonatypeRepository
[info]  https://central.sonatype.com/service/local
[info] journal-v2 / sonatypeRepository
[info]  https://central.sonatype.com/service/local
[info] state-base / sonatypeRepository
[info]  https://central.sonatype.com/service/local
[info] base-v2 / sonatypeRepository
[info]  https://central.sonatype.com/service/local
[info] sonatypeRepository
[info]  https://central.sonatype.com/service/local

Additional context The error occurs during the status check of the deployment. The current implementation does not properly handle timeout exceptions, causing the release process to fail. The error stack trace shows multiple recursive calls to didDeploySucceed, suggesting that the retry logic may be implemented inefficiently.

Error log snippet:

08:56:05.635 [main] ERROR sttp.client4.logging.slf4j.Slf4jLoggingBackend - Exception when sending request: POST https://central.sonatype.com/api/v1/publisher/status?id=dfc06ac3-f563-47f8-8381-f6037780f0c8, took: 5.103s sttp.client4.SttpClientException$TimeoutException: Exception when sending request: POST https://central.sonatype.com/api/v1/publisher/status?id=dfc06ac3-f563-47f8-8381-f6037780f0c8

https://github.com/j5ik2o/akka-persistence-dynamodb/actions/runs/11067138584/job/30750697491#step:5:945

The current implementation in SonatypeCentralClient class does not explicitly handle SttpClientException$TimeoutException, leading to unhandled timeouts and failed releases.

j5ik2o commented 1 month ago

Regarding the workaround for the bug: I was able to avoid the Read Timeout by using the following command:

sbt -Dsun.net.client.defaultReadTimeout=60000 -v ci-release

This successfully circumvents the timeout issue.