Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sbt --client "java.io.IOException: Stream Closed" exception for Play app #6515

Closed
dkovalenko opened this issue May 18, 2021 · 7 comments · Fixed by playframework/playframework#10890
Labels
area/sbtn thin client issues Bug

Comments

@dkovalenko
Copy link

dkovalenko commented May 18, 2021

steps

  1. Take play framework project
  2. Have sbt server running
  3. Try to "run" in --client mode

problem

sbt --client app/run                                          
[info] entering *experimental* thin client - BEEP WHIRR
[info] terminate the server with `shutdown`
> app/run
[warn] javaOptions will be ignored, fork is set to false

--- (Running the application, auto-reloading is enabled) ---
[info] p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

(Server started, use Enter to stop and go back to the console...)
[error] java.io.IOException: Stream Closed
[error]         at java.base/java.io.FileInputStream.available0(Native Method)
[error]         at java.base/java.io.FileInputStream.available(FileInputStream.java:330)
[error]         at play.sbt.PlayConsoleInteractionMode$InputStreamWrapper.read(PlayInteractionMode.scala:64)
[error]         at jline.internal.NonBlockingInputStream.read(NonBlockingInputStream.java:245)
[error]         at jline.internal.InputStreamReader.read(InputStreamReader.java:258)
[error]         at jline.internal.InputStreamReader.read(InputStreamReader.java:195)
[error]         at jline.console.ConsoleReader.readCharacter(ConsoleReader.java:2180)
[error]         at jline.console.ConsoleReader.readCharacter(ConsoleReader.java:2170)
[error]         at play.sbt.PlayConsoleInteractionMode$.waitEOF$1(PlayInteractionMode.scala:99)
[error]         at play.sbt.PlayConsoleInteractionMode$.$anonfun$waitForKey$2(PlayInteractionMode.scala:110)
[error]         at play.sbt.PlayConsoleInteractionMode$.$anonfun$doWithoutEcho$1(PlayInteractionMode.scala:117)
[error]         at play.sbt.PlayConsoleInteractionMode$.$anonfun$doWithoutEcho$1$adapted(PlayInteractionMode.scala:114)
[error]         at play.sbt.PlayConsoleInteractionMode$.withConsoleReader(PlayInteractionMode.scala:93)
[error]         at play.sbt.PlayConsoleInteractionMode$.doWithoutEcho(PlayInteractionMode.scala:114)
[error]         at play.sbt.PlayConsoleInteractionMode$.$anonfun$waitForKey$1(PlayInteractionMode.scala:110)
[error]         at play.sbt.PlayConsoleInteractionMode$.$anonfun$waitForKey$1$adapted(PlayInteractionMode.scala:97)
[error]         at play.sbt.PlayConsoleInteractionMode$.withConsoleReader(PlayInteractionMode.scala:93)
[error]         at play.sbt.PlayConsoleInteractionMode$.waitForKey(PlayInteractionMode.scala:97)
[error]         at play.sbt.PlayConsoleInteractionMode$.waitForCancel(PlayInteractionMode.scala:121)
[error]         at play.sbt.run.PlayRun$.$anonfun$playRunTask$3(PlayRun.scala:121)
[error]         at play.sbt.run.PlayRun$.$anonfun$playRunTask$3$adapted(PlayRun.scala:67)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] stack trace is suppressed; run last app / Compile / run for the full output
[error] (app / Compile / run) java.io.IOException: Stream Closed
[error] Total time: 4 s, completed 18 May 2021, 12:29:13

After this sbt server continues to run play application, but I can't see any output from it and can't stop it other than killing parent sbt process.

expectation

Play server is running properly in sbt --client mode, I can see the output of the server in my console, I can stop the application with Ctrl+C.

notes

Sbt version: 1.5.2
Play framework version: 2.7.9

@dkovalenko dkovalenko added the Bug label May 18, 2021
@eed3si9n
Copy link
Member

@dkovalenko Thanks for the report. Could you tell us which version of sbt and Play you're using?

If I remember correctly, there was an issue in sbt's input handling as well because JLine does its own input reading instead of the assigned System.in so we forked JLine 2 to respect it - sbt/jline2#1. Not sure if it's the same issue, but could be related.

@eed3si9n eed3si9n added the area/sbtn thin client issues label May 18, 2021
@eatkins
Copy link
Contributor

eatkins commented May 18, 2021

Yeah, play is using a FileInputStream for some reason. That will definitely not work with client mode: https://github.com/playframework/playframework/blob/53e55f017f508f0dcdf2a70327bd73153fe87e5e/dev-mode/sbt-plugin/src/main/scala/play/sbt/PlayInteractionMode.scala#L84-L87. This should probably be a play issue. They shouldn't need to create a non blocking input stream reader because sbt makes System.in non-blocking starting with 1.4.0.

@dkovalenko
Copy link
Author

@dkovalenko Thanks for the report. Could you tell us which version of sbt and Play you're using?

If I remember correctly, there was an issue in sbt's input handling as well because JLine does its own input reading instead of the assigned System.in so we forked JLine 2 to respect it - sbt/jline2#1. Not sure if it's the same issue, but could be related.

Sbt version: 1.5.2
Play framework version: 2.7.9

@dkovalenko
Copy link
Author

Yeah, play is using a FileInputStream for some reason. That will definitely not work with client mode: https://github.com/playframework/playframework/blob/53e55f017f508f0dcdf2a70327bd73153fe87e5e/dev-mode/sbt-plugin/src/main/scala/play/sbt/PlayInteractionMode.scala#L84-L87. This should probably be a play issue. They shouldn't need to create a non blocking input stream reader because sbt makes System.in non-blocking starting with 1.4.0.

Can we somehow create an issue for the play framework maintainers to fix that? I can do that but I lack some technical details and don't want to be a secondhand source.

@eed3si9n
Copy link
Member

@dkovalenko here you go - playframework/playframework#10864

@mkurz
Copy link
Member

mkurz commented Dec 19, 2021

@eed3si9n You can close this issue here, I am taking care of it in the Play repo: playframework/playframework#11061

@eed3si9n
Copy link
Member

Sounds good

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/sbtn thin client issues Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants