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

Compile error triggers multiple compilations #7753

Closed
KyleU opened this Issue Aug 24, 2017 · 30 comments

Comments

Projects
None yet
10 participants
@KyleU
Copy link

KyleU commented Aug 24, 2017

Normally, when I screw up my code and "run" my app, refreshing the web browser causes play to compile, fail, and return a "Compilation failed" page. Since upgrading to 2.6, refreshing the browser will cause the code to enter a (compile, fail, repeat) loop. It attempts to compile four times before finally returning to the browser after the last failure. I thought it was Chrome being clever and re-requesting the page, but I've reproduced it with curl as well.

Play Version

2.6.X (tested with 2.6.3)

API

Scala (maybe both)

Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)

MacOS Sierra

Expected Behavior

  1. Introduce compile error in project.
  2. Start the app with run.
  3. Refresh the browser or curl url.
  4. Play will attempt to compile once, fail, and return a "Compilation failed" page

Actual Behavior

  1. Introduce compile error in project.
  2. Start the app with run.
  3. Refresh the browser or curl url.
  4. Play will attempt to compile four times, before returning a "Compilation failed" page

Reproducible Test Case

  1. sbt new playframework/play-scala-seed.g8
  2. Introduce compile error in project (add a few random characters to the controller).
  3. Start the app with run.
  4. Refresh the browser or curl url.
  5. Play will attempt to compile four times.
[info] Compiling 1 Scala source to /Users/kyle/Temp/xxx/target/scala-2.12/classes...
[error] /Users/kyle/Temp/xxx/app/controllers/HomeController.scala:22: value xxx is not a member of play.api.mvc.Result
[error]     Ok(views.html.index())xxx
[error]                           ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[info] Compiling 1 Scala source to /Users/kyle/Temp/xxx/target/scala-2.12/classes...
[error] /Users/kyle/Temp/xxx/app/controllers/HomeController.scala:22: value xxx is not a member of play.api.mvc.Result
[error]     Ok(views.html.index())xxx
[error]                           ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] application -

! @7559l0cdj - Internal server error, for (GET) [/] ->

play.sbt.PlayExceptions$CompilationException: Compilation error[value xxx is not a member of play.api.mvc.Result]
	at play.sbt.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:27)
	at play.sbt.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:27)
	at scala.Option.map(Option.scala:145)
	at play.sbt.run.PlayReload$$anonfun$taskFailureHandler$1.apply(PlayReload.scala:49)
	at play.sbt.run.PlayReload$$anonfun$taskFailureHandler$1.apply(PlayReload.scala:44)
	at scala.Option.map(Option.scala:145)
	at play.sbt.run.PlayReload$.taskFailureHandler(PlayReload.scala:44)
	at play.sbt.run.PlayReload$.compileFailure(PlayReload.scala:40)
	at play.sbt.run.PlayReload$$anonfun$compile$1.apply(PlayReload.scala:17)
	at play.sbt.run.PlayReload$$anonfun$compile$1.apply(PlayReload.scala:17)
[info] Compiling 1 Scala source to /Users/kyle/Temp/xxx/target/scala-2.12/classes...
[error] /Users/kyle/Temp/xxx/app/controllers/HomeController.scala:22: value xxx is not a member of play.api.mvc.Result
[error]     Ok(views.html.index())xxx
[error]                           ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[info] Compiling 1 Scala source to /Users/kyle/Temp/xxx/target/scala-2.12/classes...
[error] /Users/kyle/Temp/xxx/app/controllers/HomeController.scala:22: value xxx is not a member of play.api.mvc.Result
[error]     Ok(views.html.index())xxx
[error]                           ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
@richdougherty

This comment has been minimized.

Copy link
Member

richdougherty commented Aug 28, 2017

Thanks a lot for the report. I'm not sure why we didn't notice this earlier!

I have reproduced now too. I'm on Mac OS 10.12.6 (Sierra) running Java 1.8.0_60-b27. I have reproduced on 2.6.0-2.6.3.

Script 1:

  1. remove target and project/target directories
  2. introduce error into application source
  3. sbt
  4. run
  5. request page in browswer
  6. see 3-4 compile errors.

Script 2:

  1. remove target and project/target directories
  2. fix application source so it compiles,
  3. sbt
  4. run
  5. request page in browswer
  6. compile happens (once), see page in browser
  7. introduce error into application source
  8. request page in browswer
  9. usually see 1 compile error only, but sometimes more

@richdougherty richdougherty added this to the Play 2.6.4 milestone Aug 28, 2017

@hepin1989

This comment has been minimized.

Copy link
Contributor

hepin1989 commented Aug 31, 2017

I was thought that is triggered by the sbt-scalariform plugin,seems not.

@hepin1989

This comment has been minimized.

Copy link
Contributor

hepin1989 commented Aug 31, 2017

image

it's very annoying,as it is

@richdougherty

This comment has been minimized.

Copy link
Member

richdougherty commented Aug 31, 2017

I was thought that is triggered by the sbt-scalariform plugin,seems not.

I'm assuming there's a race condition in our file watching/compiling code.

it's very annoying,as it is

Yes!

@hepin1989

This comment has been minimized.

Copy link
Contributor

hepin1989 commented Sep 14, 2017

                                     ^
[info] Set current project to beehive-facade (in build file:/C:/Users/kerr/IdeaProjects/BeehiveFacade/)
[beehive-facade] $ run

--- (Running the application, auto-reloading is enabled) ---

[info] p.c.s.AkkaHttpServer - 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...)

[info] Compiling 6 Scala sources and 1 Java source to C:\Users\kerr\IdeaProjects\BeehiveFacade\target\scala-2.12\classes...
[error] IO error while decoding C:\Users\kerr\IdeaProjects\BeehiveFacade\target\scala-2.12\routes\main\router\Routes.scala with UTF-8
[error] Please try specifying another one using the -encoding option
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[info] Compiling 6 Scala sources and 1 Java source to C:\Users\kerr\IdeaProjects\BeehiveFacade\target\scala-2.12\classes...
[error] IO error while decoding C:\Users\kerr\IdeaProjects\BeehiveFacade\target\scala-2.12\routes\main\router\Routes.scala with UTF-8
[error] Please try specifying another one using the -encoding option
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[info] Compiling 6 Scala sources and 1 Java source to C:\Users\kerr\IdeaProjects\BeehiveFacade\target\scala-2.12\classes...
[error] IO error while decoding C:\Users\kerr\IdeaProjects\BeehiveFacade\target\scala-2.12\routes\main\router\Routes.scala with UTF-8
[error] Please try specifying another one using the -encoding option
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] application -

! @75b532609 - Internal server error, for (GET) [/robots.txt] ->

play.sbt.PlayExceptions$CompilationException: Compilation error[IO error while decoding C:\Users\kerr\IdeaProjects\BeehiveFacade\target\sca
la-2.12\routes\main\router\Routes.scala with UTF-8
Please try specifying another one using the -encoding option]
        at play.sbt.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:27)
        at play.sbt.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:27)
        at scala.Option.map(Option.scala:145)
        at play.sbt.run.PlayReload$$anonfun$taskFailureHandler$1.apply(PlayReload.scala:49)
        at play.sbt.run.PlayReload$$anonfun$taskFailureHandler$1.apply(PlayReload.scala:44)
        at scala.Option.map(Option.scala:145)
        at play.sbt.run.PlayReload$.taskFailureHandler(PlayReload.scala:44)
        at play.sbt.run.PlayReload$.compileFailure(PlayReload.scala:40)
        at play.sbt.run.PlayReload$$anonfun$compile$1.apply(PlayReload.scala:17)
        at play.sbt.run.PlayReload$$anonfun$compile$1.apply(PlayReload.scala:17)
[info] Compiling 6 Scala sources and 1 Java source to C:\Users\kerr\IdeaProjects\BeehiveFacade\target\scala-2.12\classes...
[error] IO error while decoding C:\Users\kerr\IdeaProjects\BeehiveFacade\target\scala-2.12\routes\main\router\Routes.scala with UTF-8
[error] Please try specifying another one using the -encoding option
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] application -

! @75b53290k - Internal server error, for (GET) [/beehive/explorer] ->

play.sbt.PlayExceptions$CompilationException: Compilation error[IO error while decoding C:\Users\kerr\IdeaProjects\BeehiveFacade\target\sca
la-2.12\routes\main\router\Routes.scala with UTF-8
Please try specifying another one using the -encoding option]
        at play.sbt.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:27)
        at play.sbt.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:27)
        at scala.Option.map(Option.scala:145)
        at play.sbt.run.PlayReload$$anonfun$taskFailureHandler$1.apply(PlayReload.scala:49)
        at play.sbt.run.PlayReload$$anonfun$taskFailureHandler$1.apply(PlayReload.scala:44)
        at scala.Option.map(Option.scala:145)
        at play.sbt.run.PlayReload$.taskFailureHandler(PlayReload.scala:44)
        at play.sbt.run.PlayReload$.compileFailure(PlayReload.scala:40)
        at play.sbt.run.PlayReload$$anonfun$compile$1.apply(PlayReload.scala:17)
        at play.sbt.run.PlayReload$$anonfun$compile$1.apply(PlayReload.scala:17)
[info] Compiling 6 Scala sources and 1 Java source to C:\Users\kerr\IdeaProjects\BeehiveFacade\target\scala-2.12\classes...
[error] IO error while decoding C:\Users\kerr\IdeaProjects\BeehiveFacade\target\scala-2.12\routes\main\router\Routes.scala with UTF-8
[error] Please try specifying another one using the -encoding option
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[info] Compiling 6 Scala sources and 1 Java source to C:\Users\kerr\IdeaProjects\BeehiveFacade\target\scala-2.12\classes...
[INFO] [09/15/2017 00:43:19.868] [Thread-4] [CoordinatedShutdown(akka://play-dev-mode)] Starting coordinated shutdown from JVM shutdown hoo
k
[error] IO error while decoding C:\Users\kerr\IdeaProjects\BeehiveFacade\target\scala-2.12\routes\main\router\Routes.scala with UTF-8
[error] Please try specifying another one using the -encoding option
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[info] Compiling 6 Scala sources and 1 Java source to C:\Users\kerr\IdeaProjects\BeehiveFacade\target\scala-2.12\classes...
[error] IO error while decoding C:\Users\kerr\IdeaProjects\BeehiveFacade\target\scala-2.12\routes\main\router\Routes.scala with UTF-8
[error] Please try specifying another one using the -encoding option
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[info] Compiling 6 Scala sources and 1 Java source to C:\Users\kerr\IdeaProjects\BeehiveFacade\target\scala-2.12\classes...
[error] IO error while decoding C:\Users\kerr\IdeaProjects\BeehiveFacade\target\scala-2.12\routes\main\router\Routes.scala with UTF-8
[error] Please try specifying another one using the -encoding option
[error] one error found
[error] (compile:compileIncremental) Compilation failed
终止批处理操作吗(Y/N)? ^C

@marcospereira marcospereira modified the milestones: Play 2.6.5, Play 2.6.6 Sep 18, 2017

@marcospereira marcospereira modified the milestones: Play 2.6.6, Play 2.6.7 Oct 17, 2017

@marcospereira marcospereira modified the milestones: Play 2.6.7, Play 2.6.8 Nov 3, 2017

@sergeych

This comment has been minimized.

Copy link

sergeych commented Nov 30, 2017

It is very annoying. Why do you keep postponing it?

@marcospereira marcospereira modified the milestones: Play 2.6.9, Play 2.7.0 Dec 12, 2017

@shkhln

This comment has been minimized.

Copy link
Contributor

shkhln commented Dec 12, 2017

Well, it looks like Play indeed triggers reload 4 times per request.

@shkhln

This comment has been minimized.

Copy link
Contributor

shkhln commented Dec 13, 2017

And then it sets forceReloadNextTime = true on on each compilation failure.

@sergeych

This comment has been minimized.

Copy link

sergeych commented Dec 14, 2017

Yes, I've seen it - that it reloads multiple times, it's very annoying itself, and with errors - it's a real pain. Most often I can figure out the error before play stops flooding logs with repeating error messages ;) Multiple reloading therefore makes play hardly usable in professional development, as it slows it down and reduces developer hour outcome, what is a critical flaw.

@nemoo

This comment has been minimized.

Copy link

nemoo commented Dec 14, 2017

This issue renders recent performance improvements of the scala platfortform pretty much irrelevant. This increases the compile time in case of an error by 300% (4 times). And it does so in a very annoying way because as son as your eyes fixate on an error message, it recompiles again and your eyes lose focus on the error. Given that this produces an extremely bad user experience when working with play framework, please consider increasing the priority of this issue.

@gavares

This comment has been minimized.

Copy link
Contributor

gavares commented Jan 14, 2018

I agree with @nemoo. Postponing a fix for this to Play 2.7 seems like the wrong prioritization for this issue.

This bug has real and tangible effect on development speed. Considering that scala code compilation is not particularly fast to begin with, paying to compile 4 times per change when there is an error can result in very long edit-compile cycles for even the smallest of changes.

Surprising to see this bug still open after nearly 6 months and, given that 2.7 has no set due date in the milestone, there is still no fix in sight.

@richdougherty

This comment has been minimized.

Copy link
Member

richdougherty commented Jan 14, 2018

I'll raise this issue at our next team meeting. I've put a help wanted tag on this just in case someone else wants to contribute in the meantime.

@richdougherty richdougherty modified the milestones: Play 2.7.0, Play 2.6.x Jan 16, 2018

@sergeych

This comment has been minimized.

Copy link

sergeych commented Jan 17, 2018

@sergeych

This comment has been minimized.

Copy link

sergeych commented May 2, 2018

Great why don't you include this fix into closest release? We're waiting for it...

@shkhln

This comment has been minimized.

Copy link
Contributor

shkhln commented May 3, 2018

You are missing out. The fix has been backported to the 2.6.x branch (#8169) and is available since 2.6.12.

@sergeych

This comment has been minimized.

Copy link

sergeych commented May 3, 2018

great! thanks!

@easel

This comment has been minimized.

Copy link
Contributor

easel commented May 8, 2018

I'm still seeing the "compiles 4x" behavior using play 2.6.13. Can anyone verify that the fix in 2.6.12+ is working?

@Enalmada

This comment has been minimized.

Copy link
Contributor

Enalmada commented May 8, 2018

I am on 2.6.13 and I still see every compile error what seems like 3 times. It is extremely annoying...I find myself trying to copy text in the terminal to freeze it so I can read the error without having to wait forever for the looping to finish. Definitely makes development using play punishing. On Windows 10 using sbt 1.1.4 doing sbt then run.

@shkhln

This comment has been minimized.

Copy link
Contributor

shkhln commented May 8, 2018

I'm still seeing the "compiles 4x" behavior using play 2.6.13.

Four times exactly or just multiple times?

Can anyone verify that the fix in 2.6.12+ is working?

Works for me.

@nemoo

This comment has been minimized.

Copy link

nemoo commented May 8, 2018

I just tested using 2.6.12 and I see compile errors at least twice, sometimes three times after a single code change. On Windows 10; sbt 1.1.0; sbt ~run

@shkhln

This comment has been minimized.

Copy link
Contributor

shkhln commented May 8, 2018

Well, I truly hate pointing it out, but it's a pretty simple issue to debug. Anyone?

@Enalmada

This comment has been minimized.

Copy link
Contributor

Enalmada commented May 29, 2018

Perhaps it is something specific to windows 10...is anyone seeing this error not on windows 10?

@shkhln Are you asking for someone with the problem to create a similar gist of a Thread.dumpStack() in DevServerStart while the redundant recompiles are going? I contribute to docs and modules where I can but I have no play debug experience so I am hoping someone that does with Windows 10 around can step up. But this is such I high severity issue I will do whatever I can to follow specific directions to get my env up to a place I can generate logs that could help...or I can let someone who knows what they are doing remote connect. I appreciate everyone that has contributed to this as the multiple recompile really kills productivity.

@shkhln

This comment has been minimized.

Copy link
Contributor

shkhln commented May 29, 2018

Are you asking for someone with the problem to create a similar gist of a Thread.dumpStack() in DevServerStart while the redundant recompiles are going?

Yes. It's also possible to use btrace to obtain that information if you don't want to recompile Play.

@easel

This comment has been minimized.

Copy link
Contributor

easel commented May 30, 2018

It happens on MacOS as well as windows.

@KyleU

This comment has been minimized.

Copy link
Author

KyleU commented May 30, 2018

2.6.12 fixed it for me, MacOS/GraalVM. I haven't seen the multiple compile issue since then, but can reproduce it by downgrading to .11.

@Enalmada

This comment has been minimized.

Copy link
Contributor

Enalmada commented May 30, 2018

btrace is an good suggestion and worth knowing about for future problems. If anyone ever tries it in the future be sure to look in the samples directory for script examples.

I got playframework debug env going despite some windows 10 charset issue that I hacked around for now. Looking closely at the output I now notice that every time I refresh the browser I have 3 duplicate errors but the actual reason is that the browser is making three calls per refresh:

  1. /service-worker.js
  2. /current-browser-url
  3. /favicon.ico

All I would have expected is my current-browser-url. I am not sure why the service-worker.js script feels the need to hit the server on an error page and I will look into that. The favicon.ico is apparently a chrome issue and the solution seems to be to put a "empty" link tag in the devError page head so chrome doesn't try and hit the server for the default one causing another recompile error in the console. I assume that everyone developing with play on chrome must be seeing at least two errors every browser refresh because of this?

@easel

This comment has been minimized.

Copy link
Contributor

easel commented May 30, 2018

@Enalmada that's a good catch, I'm sure some of my duplicate refreshes are due to exactly that. All that being said, the dev server really ought to be catching all inbound requests and attaching them to a single recompile, not kicking off new ones for every inbound request.

@shkhln

This comment has been minimized.

Copy link
Contributor

shkhln commented May 30, 2018

/favicon.ico

That's funny, favicon was only recently removed to (partially) satisfy a pretty absurd set of demands. Some people really should learn to say 'No' more often.

@Enalmada

This comment has been minimized.

Copy link
Contributor

Enalmada commented May 30, 2018

Doh. Someone went overboard removing them from all templates...they should have only done the production templates to satisfy the demands. The favicon should go back into devError.scala.html to avoid the additional recompile hit to all developers using chrome.

@Enalmada

This comment has been minimized.

Copy link
Contributor

Enalmada commented May 30, 2018

@easel Agreed. Is there any chance of having an incoming request only trigger a recompile if anything has changed since the last recompile? That would eliminate the performance impact from service workers and browsers doing their quirky lookups for extra files causing completely redundant and unnecessary recompilations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment