[2.x] fix: stack traces suppressed in thin client batch mode (#9058)

In sbt 2.x, running batch commands through the thin client (sbtn) suppresses stack traces for all tasks because the server's shell command unconditionally sets state.interactive = true. This causes LogManager.defaultTraceLevel to return -1 (suppressed) even when the client explicitly signals non-interactive (batch) mode via Attach(interactive=false).

This fixes the shell command to check the originating NetworkChannel's interactive flag before setting state.interactive, so thin client batch commands correctly get Int.MaxValue trace level and display full stack traces.
This commit is contained in:
BitToby 2026-04-13 00:24:30 +02:00 committed by GitHub
parent c52ce78d77
commit 05cd00e135
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 1 deletions

View File

@ -1144,12 +1144,20 @@ object BuiltinCommands {
.getOpt(Keys.minForcegcInterval)
.getOrElse(GCUtil.defaultMinForcegcInterval)
val exec: Exec = getExec(s1, minGCInterval)
val isInteractive = exec.source match {
case Some(src) if src.channelName.startsWith("network") =>
exchange.channelForName(src.channelName) match {
case Some(nc: NetworkChannel) => nc.isInteractive
case _ => true
}
case _ => true
}
val newState = s1
.copy(
onFailure = Some(Exec(Shell, None)),
remainingCommands = exec +: Exec(Shell, None) +: s1.remainingCommands
)
.setInteractive(true)
.setInteractive(isInteractive)
val res =
if (exec.commandLine.trim.isEmpty) newState
else newState.clearGlobalLog

View File

@ -0,0 +1,11 @@
lazy val helloWithoutStreams = taskKey[Unit]("")
lazy val helloWithStreams = taskKey[Unit]("")
helloWithoutStreams := {
throw new RuntimeException("boom without streams!")
}
helloWithStreams := {
val log = streams.value.log
throw new RuntimeException("boom with streams!")
}

View File

@ -0,0 +1,2 @@
-> helloWithoutStreams
-> helloWithStreams