Hi folks, I’m running into a problem when invoking workspace.updateWorkspaceFolders() twice in a row. The problem is that the the code in workspaceService.spliceRoots() is not concurrency-safe, but my two invocations seem to be running concurrently. Is there a some policy about running api requests in parallel? How can we enforce thread-safety here?
[original thread by Thomas Mäder]
Hi, what kind of bad effects you get?
Is this such a hard question or is spectrum broken?
the first operation wins over the second?
Ok, so spectrum was broken:
you get a dialog asking whether you want to overwrite the workspace file. It’s an out-of-sync problem.
the problem is that both executions get to “readWorkspaceFile” before the first gets to “writeWorkspaceFile”
we need a queue there to apply workspace modifications in proper order
Generally, how is concurrency handled in Theia?
generally we have queues in places where code is async but should be handled as an atomic operation
if it is sync code, then there is nothing to worry about
i don’t think though that it is only about
splitRoots, we need to make sure that all apis which modifie a workspace-file is thread-safe
Maybe it’s a good idea to offer some library code for solving such problems.
we could generalize as a class into
promise-util in core