Ensure execution is scheduled after compilation (#10883)

Scheduling of jobs is asynchronous and nothing prevents it from scheduling execution before compilation leading to stale nodes in GUI. The scenario is easily reproducible by adding a `Thread.sleep` before `EnsureCompiledJob` requests compilation locks.

This change ensures that execution is only scheduled after compilation is finished, when an edit request is being processed.

# Important Notes
This fix was prompted by me getting random stale nodes after edits:
![Screenshot from 2024-08-23 16-53-26](https://github.com/user-attachments/assets/2b017539-c4bf-4d42-b597-216d887a4f4c)
(it would never recover unless another edit was made)
This commit is contained in:
Hubert Plociniczak 2024-08-23 20:18:59 +02:00 committed by GitHub
parent 3bfe963e32
commit 3d23e22c6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -52,8 +52,9 @@ class EditFileCmd(request: Api.EditFileNotification)
}
if (request.execute) {
ctx.jobControlPlane.abortAllJobs()
ctx.jobProcessor.run(new EnsureCompiledJob(Seq(request.path)))
executeJobs.foreach(ctx.jobProcessor.run)
ctx.jobProcessor
.run(new EnsureCompiledJob(Seq(request.path)))
.foreach(_ => executeJobs.foreach(ctx.jobProcessor.run))
} else if (request.idMap.isDefined) {
ctx.jobProcessor.run(new EnsureCompiledJob(Seq(request.path)))
}