Bloop: Handle cancellation of the REPL

Created on 3 May 2018  Â·  3Comments  Â·  Source: scalacenter/bloop

For consistency with the rest of operations, the REPL should be gracefully cancelled whenever CtrlC is typed, otherwise the execution will never stop and could cause a potential deadlock. Currently, users can gracefully cancel it by typing :q as they usually do.

enhancement ergonomics help wanted task / console

All 3 comments

Do you mean it should be handled inside the client by catching SIGINT or inside the server by detecting if a client disconnected unexpectedly?

For the record, EOF (Ctrl+D) is already working as expected.

I meant the latter. The logic to handle cancellation is already present in ‘Cli.scala’ but it has no effect for console because we don’t do ‘doOnCancel’ upon the creation of the console task.

This one was a bit tricky, because AnalyzingCompiler.console returns Unit, so obviously there's no way to close it externally. However, the REPL also exits when it encounters EOF.

We can expect Nailgun to close stdin when a client disconnects, and indeed it seems to be the case: I attached a debugger and set a breakpoint in:
https://github.com/scalacenter/zinc/blob/0f4ad9d59f3f366d272f28aeec7949a5763018cb/internal/compiler-bridge/src/main/scala_2.11-12/xsbt/ConsoleInterface.scala#L72
The breakpoint was hit when typing :q, when pressing ctrl+D (manually sending EOF) and when pressing ctrl+C (sending SIGINT), so I think we can safely assume that cancellation is already handled.

I'm closing this issue for now, but if someone finds any evidence my assumptions aren't correct, feel free to reopen it.

Was this page helpful?
0 / 5 - 0 ratings