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

organizeImports causes "WARN Aborted codeActionsOnSave after 750ms" #5534

Closed
ablakey opened this issue May 1, 2019 · 6 comments
Closed

organizeImports causes "WARN Aborted codeActionsOnSave after 750ms" #5534

ablakey opened this issue May 1, 2019 · 6 comments
Labels
area-formatting feature-request Request for new features or functionality needs proposal Need to make some design decisions

Comments

@ablakey
Copy link

ablakey commented May 1, 2019

I'm looking for advice on how to debug this myself. My current thought is that the underlying system(s) that organize imports for Python are taking a long time, which may be an environment issue with my machine. I'm not sure where to start looking.

Environment data

Version: 1.33.1
Commit: 51b0b28134d51361cf996d2f0a1c698247aeabd8
Date: 2019-04-11T08:20:22.771Z
Electron: 3.1.6
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Linux x64 4.18.0-18-generic
Python version (& distribution if applicable, e.g. Anaconda): 3.6 installed with Bionic.
Type of virtual environment used (N/A | venv | virtualenv | conda | ...): NA
Relevant/affected Python packages and their versions: 3.6 maybe others

Expected behaviour

When organizeImports is true it should organize imports on save with little delay.

Actual behaviour

Imports are organized, but there's almost a 1 second blank pause for the file to be saved (and for the little "unsaved changes" dot to disappear from the file header.

Steps to reproduce:

  1. Have this set in settings.json:
{
  "[python]": {
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
    }
  }
  1. Put together a short Python file with some stdlib imports that are out of order.

  2. Save the file.

Logs

 WARN Aborted codeActionsOnSave after 750ms   log.ts:167
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label May 1, 2019
@ablakey
Copy link
Author

ablakey commented May 9, 2019

I'm not precisely sure what is wrong, but I fixed the issue by installing the latest isort manually and then setting: "python.sortImports.path": "/usr/local/bin/isort"

It may be that isort needs to be bumped in the next release?

@DonJayamanne
Copy link

Solution

  • Increase default timeout to 1s or longer
  • Ship this default value as part of extension

@DonJayamanne DonJayamanne added good first issue needs PR bug Issue identified by VS Code Team member as probable bug labels May 16, 2019
@ghost ghost removed triage-needed Needs assignment to the proper sub-team labels May 16, 2019
@DonJayamanne DonJayamanne added triage-needed Needs assignment to the proper sub-team area-formatting labels May 16, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label May 16, 2019
@ablakey
Copy link
Author

ablakey commented May 16, 2019

Will bumping the version of isort included happen elsewhere? Doing so manually had a significant impact on performance.

I'll give this a spin when I get in to work tomorrow.

@DonJayamanne
Copy link

#5642

@ethan-deng
Copy link

This setting is not working. The unused imports are not removed.

Version: 1.37.1 (user setup)
Commit: f06011ac164ae4dc8e753a3fe7f9549844d15e35
Date: 2019-08-15T16:17:55.855Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.16299

@luabud luabud added needs proposal Need to make some design decisions feature-request Request for new features or functionality and removed good first issue reason-preexisting bug Issue identified by VS Code Team member as probable bug labels Sep 15, 2020
@luabud luabud self-assigned this Sep 15, 2020
@luabud luabud removed their assignment May 12, 2022
@github-actions github-actions bot removed the needs PR label Aug 9, 2022
@karthiknadig
Copy link
Member

Please try the isort extension, it uses Language Server protocol to handle import organization, and should perform better as isort is not run for scratch each time.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-formatting feature-request Request for new features or functionality needs proposal Need to make some design decisions
Projects
None yet
Development

No branches or pull requests

5 participants