mirror of https://github.com/sbt/sbt.git
[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:
parent
c52ce78d77
commit
05cd00e135
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Reference in New Issue