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

Multiple code actions conflict due to a race condition #90220

Closed
Spenhouet opened this issue Feb 7, 2020 · 6 comments
Closed

Multiple code actions conflict due to a race condition #90220

Spenhouet opened this issue Feb 7, 2020 · 6 comments
Assignees
Labels
*caused-by-extension Issue identified to be caused by an extension editor-code-actions Editor inplace actions (Ctrl + .)
Milestone

Comments

@Spenhouet
Copy link

Environment:

  • VSCode Version: 1.42
  • OS Version: Windows 10 v1809
    Does this issue occur when all extensions are disabled?: No

Issue:

This is what happens when only pressing save once (only input 1 x STRG+S):
test

This is due to multiple code actions running in parallel.
This is not an issue with the extensions them self (I tested them independently and they work fine), this is a VS code issue.

Steps to Reproduce:

  1. Install the Python and Pyright extensions.
    • ms-python.python
    • ms-pyright.pyright
  2. Use the following VS code settings:
    {
        "editor.formatOnSave": false,
        "python.jediEnabled": false,
        "[python]": {
            "editor.codeActionsOnSave": {
                "source.organizeImports": true,
            }
        }
    }
    
  3. Create an empty python file
  4. Insert this import statement:
    from test_module import (test_method_1, test_method_2, test_method_3, test_method_4, 
                             test_method_5, test_method_6)
    
  5. Save (STRG + S)

Possible solution:

Code action providers should run successively.

Others:

I want to mention that code actions and formatting also conflicts with a race condition. This should also be addressed independently and is tracked here: #83586

@mjbvz
Copy link
Collaborator

mjbvz commented Apr 9, 2020

This seems like the same issue as #83586 When I investigated the issue, it seems that VS Code is doing the right thing. However it is possible there is a bug in the extensions.

VS Code executes the actions in the correct order but extensions need to return a promise that tracks when they have completed editing the file. If an extension does not do this, we will try executing the next actions before the previous one completed

Please try following up with the python extensions on this. If they come back and say that VS Code really is doing the wrong thing, we will take a look.

@mjbvz mjbvz closed this as completed Apr 9, 2020
@mjbvz mjbvz added the *caused-by-extension Issue identified to be caused by an extension label Apr 9, 2020
@mjbvz mjbvz modified the milestones: April 2020, Backlog Apr 9, 2020
@mjbvz mjbvz added the editor-code-actions Editor inplace actions (Ctrl + .) label Apr 9, 2020
@Spenhouet
Copy link
Author

@mattbierner You did see that the editor.formatOnSave was set to false?

It has nothing to do with formatting. It has nothing to do with the issue you linked... in which I was also active.
Please confirm that you checked with formatting turned off.
Please reopen if closing this was a mistake.

@Spenhouet
Copy link
Author

Spenhouet commented Apr 10, 2020

@mattbierner I also already did what you are asking me to do before opening the issue here. Did you look at the linked issues before posting your comment and closing this issue? I reported this issue on the vscode-python extension before opening this issue here, see: microsoft/vscode-python#9889

Could you please reopen this issue?

@Spenhouet
Copy link
Author

@mattbierner I also want to make sure that it is clear that the extensions independently work without any issues.

I checked the code of the pyright extension and it looks to me like they are returning the promise as you expect: https://github.com/microsoft/pyright/blob/master/client/src/progress.ts

So I guess we are back here. Could you please reopen.

@mjbvz
Copy link
Collaborator

mjbvz commented Apr 14, 2020

@Spenhouet Yes. I'd really like an extension author to look at this and tell me what exactly VS Code is doing wrong here. There's are many cases where it's the extension themselves misbehaving so I'd really like to know what the issue is from the extension's point of view before diving into this

@Spenhouet
Copy link
Author

Spenhouet commented May 15, 2020

I don't know since when this option is available but I did see that pyright now has the option to disable their import organizer. This does not solve the underlying issue!
But, it is a workaround. Since with the pyright import organizer disabled only one code action is active, the above mentioned issues does no longer appear.

"pyright.disableOrganizeImports": true,

@github-actions github-actions bot locked and limited conversation to collaborators May 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*caused-by-extension Issue identified to be caused by an extension editor-code-actions Editor inplace actions (Ctrl + .)
Projects
None yet
Development

No branches or pull requests

2 participants