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

bugfix: deduplicate auto connect for scala-cli #6259

Merged
merged 5 commits into from Apr 12, 2024

Conversation

kasiaMarek
Copy link
Contributor

@kasiaMarek kasiaMarek commented Mar 27, 2024

resolves: #6257

otherDeleteEvents.map(toPath).foreach(onDelete)
// when metals creates `.bsp/<name>.json` files we want to ignore
// create event for those files
val ignoreJsonCreation = expectBspConfigCreation.get
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this change? Could we just not connect to the server created if we are currently connecting already? So maybe ignore things in onBuildChangedUnbatched ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could we just not connect to the server created if we are currently connecting already?

Yes and that is probably the proper fix want to have. The tricky part is that we need to be able to cancel if it gets stuck. I think we have some timeouts but I'm not sure on which parts and still the user might prefer to switch build server right away instead of waiting for the timeout. In that case we should cancel the old connection attempt. (#2563)

So maybe ignore things in onBuildChangedUnbatched ?

That file is created before we start connecting. I guess we can ignore things in onBuildChangedUnbatched from before creating json until we finish connecting. But then if in the meantime someone creates build.sbt it won't suggest connecting to sbt at all. Let me see if I can come up with a better way to simplify this.

Anyway this PR is not a proper fix it just deduplicates things for scala-cli but it doesn't resolve the underlying issue. I'd still be pro pushing a workaround because for scala-cli it's very visibly causing issues now and creating a proper fix might be a bit more complex.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up ignoring everything in onBuildChangedUnbatched until finishes connecting/reconnecting.

@kasiaMarek kasiaMarek force-pushed the i6257 branch 2 times, most recently from 360e054 to 0bdb71c Compare April 2, 2024 12:19
@kasiaMarek kasiaMarek requested a review from tgodzik April 5, 2024 09:04
onBuildToolsAdded(chosenBuildTool, changedBuilds)
case _ => Future.unit
): Future[Unit] =
if (willGenerateBspConfig.get().nonEmpty) Future.unit
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just:

Suggested change
if (willGenerateBspConfig.get().nonEmpty) Future.unit
if (isConnecting.get()) Future.unit

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't use isConnecting flag since it's raised after .bsp/<name>.json is created. I could raise it earlier but then I'd have to do it in many places to have it pair its name.

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

@kasiaMarek kasiaMarek merged commit 1f16fcc into scalameta:main Apr 12, 2024
25 of 26 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.

Unique index or primary key violation
2 participants