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

improvement: add timeout to fix java version for sbt request #5715

Merged

Conversation

kasiaMarek
Copy link
Contributor

No description provided.

@kasiaMarek kasiaMarek force-pushed the timeout-fix-java-version-request branch from d85707f to 52138d0 Compare October 5, 2023 10:34
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just one question

@@ -206,6 +208,8 @@ case class SbtBuildTool(
shutdownBspServer(shellRunner).ignoreValue
case _ => Future.successful(())
}
.withTimeout(10, TimeUnit.SECONDS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IS this the timeout of message requests in VS Code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More like 15sec. But I also realised that this wasn't very smart, since if you'd press the restart button after the timeout (which you always can do) it would simply shut down the sbt server. I fixed that now.

@kasiaMarek kasiaMarek requested a review from tgodzik October 6, 2023 15:55
.asScala
.flatMap {
case Messages.SbtServerJavaHomeUpdate.restart =>
if (promise.isCompleted) restartSbtBuildServer()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

completing the promise will only happen after this future is finished, so this condition will always be false, no?

Copy link
Contributor Author

@kasiaMarek kasiaMarek Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't think you're right. The promise is completed by (...).withTimeout(...), so a new future with await inside. The original Future, won't get cancelled, 'cause you can't cancel futures in Scala, so this is the code that will be executed when the user chooses restart after the timeout. (Which you can do in VSCode, 'cause the notifications are stored.) Am I wrong?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you're right. I didn't think about the after 15 seconds part. Might be good to add some comments, since it doesn't seem easy to follow.

Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

.asScala
.flatMap {
case Messages.SbtServerJavaHomeUpdate.restart =>
if (promise.isCompleted) restartSbtBuildServer()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you're right. I didn't think about the after 15 seconds part. Might be good to add some comments, since it doesn't seem easy to follow.

@kasiaMarek kasiaMarek force-pushed the timeout-fix-java-version-request branch from b4c86be to 6ff50be Compare October 10, 2023 13:28
@kasiaMarek kasiaMarek merged commit 05452ea into scalameta:main Oct 11, 2023
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants