Skip to content

Commit 091066c

Browse files
Try-catch-log BSP watchAndWait call (#6087)
Tries to work around #5965 --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 17f4854 commit 091066c

File tree

1 file changed

+35
-21
lines changed

1 file changed

+35
-21
lines changed

runner/daemon/src/mill/daemon/MillMain0.scala

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -393,29 +393,43 @@ object MillMain0 {
393393
watched = watchRes.watched
394394
)
395395

396+
def waitWithoutWatching() = {
397+
Some {
398+
try Success(Await.result(sessionResultFuture, Duration.Inf))
399+
catch {
400+
case NonFatal(ex) =>
401+
Failure(ex)
402+
}
403+
}
404+
}
405+
396406
val res =
397-
if (config.bspWatch)
398-
Watching.watchAndWait(
399-
watchRes.watched,
400-
Watching.WatchArgs(
401-
setIdle = setIdle,
402-
colors = mill.internal.Colors.BlackWhite,
403-
useNotify = config.watchViaFsNotify,
404-
daemonDir = daemonDir
405-
),
406-
() => sessionResultFuture.value,
407-
"",
408-
watchLogger.info(_)
409-
)
410-
else {
411-
watchLogger.info("Watching of build sources disabled")
412-
Some {
413-
try Success(Await.result(sessionResultFuture, Duration.Inf))
414-
catch {
415-
case NonFatal(ex) =>
416-
Failure(ex)
417-
}
407+
if (config.bspWatch) {
408+
try {
409+
Watching.watchAndWait(
410+
watchRes.watched,
411+
Watching.WatchArgs(
412+
setIdle = setIdle,
413+
colors = mill.internal.Colors.BlackWhite,
414+
useNotify = config.watchViaFsNotify,
415+
daemonDir = daemonDir
416+
),
417+
() => sessionResultFuture.value,
418+
"",
419+
watchLogger.info(_)
420+
)
421+
} catch {
422+
case e: Exception =>
423+
val sw = new java.io.StringWriter
424+
e.printStackTrace(new java.io.PrintWriter(sw))
425+
watchLogger.info(
426+
"Watching of build sources failed:" + e + "\n" + sw
427+
)
428+
waitWithoutWatching()
418429
}
430+
} else {
431+
watchLogger.info("Watching of build sources disabled")
432+
waitWithoutWatching()
419433
}
420434

421435
// Suspend any BSP request until the next call to startSession

0 commit comments

Comments
 (0)