mirror of
https://github.com/sbt/sbt.git
synced 2026-08-22 06:07:24 +02:00
[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:
@@ -1088,12 +1088,20 @@ object BuiltinCommands {
|
|||||||
.getOpt(Keys.minForcegcInterval)
|
.getOpt(Keys.minForcegcInterval)
|
||||||
.getOrElse(GCUtil.defaultMinForcegcInterval)
|
.getOrElse(GCUtil.defaultMinForcegcInterval)
|
||||||
val exec: Exec = getExec(s1, minGCInterval)
|
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
|
val newState = s1
|
||||||
.copy(
|
.copy(
|
||||||
onFailure = Some(Exec(Shell, None)),
|
onFailure = Some(Exec(Shell, None)),
|
||||||
remainingCommands = exec +: Exec(Shell, None) +: s1.remainingCommands
|
remainingCommands = exec +: Exec(Shell, None) +: s1.remainingCommands
|
||||||
)
|
)
|
||||||
.setInteractive(true)
|
.setInteractive(isInteractive)
|
||||||
val res =
|
val res =
|
||||||
if (exec.commandLine.trim.isEmpty) newState
|
if (exec.commandLine.trim.isEmpty) newState
|
||||||
else newState.clearGlobalLog
|
else newState.clearGlobalLog
|
||||||
|
|||||||
@@ -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!")
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
-> helloWithoutStreams
|
||||||
|
-> helloWithStreams
|
||||||
Reference in New Issue
Block a user