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
Exception when attempting to compute the file changes for the file move: Server error: The edit.getRefactoring
request was cancelled."
#42710
Comments
@lrhn When will this be fixed? It is impossible to work with this. |
I'm not on the analyzer team, so I wouldn't be able to answer that. Let's see if the analyzer team has a comment. |
Any updates on this? This is still happening on flutter 2.0.5 and android studio 4.1.3. |
Flutter 2.2.1, Android Studio 4.2.1, still an issue. |
I believe this happens when you move multiple files that are interdependent. So there must be a logic to move the files that are not dependent first, change their reference, and then move the others. An alternative is move file by file (one by one) |
This behavior happens only on windows. I've tested with linux an it worked as expected (except when you move the whole folder, refactoring doesn't work (neither windows nor linux)). |
@DanTup Is this something you could look at? |
@bwilkerson is there a way to enable the instrumentation log in Android Studio? I tried searching the settings but can't find anywhere to add additional args. I can't reproduce this specific error message, but it does fail for me on Windows in Android Studio with the following error:
My feeling is that these messages could be caused by:
In VS Code, the renames go through a queue so they won't be sent concurrently (since VS Code may also call us multiple times if multiple items are dragged) - should AS do the same? Related: I have an open change for supporting renaming folders (https://dart-review.googlesource.com/c/sdk/+/158005) which I'm hoping to be able to merge soon (I'm waiting for a new VS Code LSP client to be published for some final testing/tweaking of cancellation). It doesn't help with multiple items being renamed/moved together but that's probably a logical next step (either by extending the protocol to support multiple items, or handling concurrent renames). |
Yes. Open "Help > Find Action...". Search for "Registry..." and run the action. Search for "dart.server.additional.arguments" and edit it to add command-line arguments that will be sent to the server. Finally, restart the server. |
Thanks! I still can't repro the original error message, but I see that report is quite old now. @aliyazdi75 can you confirm if you're seeing the same error noted in the title ("request was cancelled") or something else (perhaps the same issue I'm seeing?). @bwilkerson for the error I'm seeing (log below), the issue seems to be that when computing edits for a rename, the references to that file are checked to see if they're package URIs or not, and that involves reading their content. However if they were renamed just before their content was read, the read fails. Eg.:
I can't think of a simple fix, although I suspect retrying the refactor after this happened (perhaps after a short delay) would succeed, as the renamed file would've been handled and the new rename would be looking at the reference from its new location, not the old one.
Edit: I also realise why VS Code doesn't see this - we currently make no attempt to handle multi-item renames in LSP (the "queue" was pre-LSP) so the refactor never runs when dragging multiple files there. |
I think your analysis is correct. I can think of two possible solutions. The first is to re-order the events on the client side. If we were to make all of the changes to each file before asking to move the next then we'd simulate a series of individual file moves, which is what server currently supports. The second is to support multi-file moves in server directly. This is probably more work, but might be a little faster. I don't remember enough about how this is implemented to know what the risks of these two approaches are. |
I think this is very similar to the in-progress changes to support directories (since we just collect all the files in the directory and enumerate through them). It would need an update to the protocol (for Android Studio - LSP already accepts multiple) and an update to the Android Studio plugin, but it probably is the best option (and something I'd like to do after landing the other changes). The directory work is partly blocked for LSP (waiting on a new LSP client release, but also trying to handle more cases where we have inconsistent Edit: That said, if we go down that route, it should probably be documented that clients should not send MOVE_FILES while also renaming files on disk in this way, since this error would remain a possibility. |
@DanTup |
Still happens to me on MacOS and Flutter 3. Exactly same error message. |
I'm also facing this problem and with every new version of Android Studio, I say to myself "maybe they solved the problem in this version", but no 😅 However, there is a way for me to solve this problem in a very simple and easy manner from within Android Studio (or vs code) When I:
This problem occurs. What is the solution for me?Suppose we have a directory like:
|
Same problem for me. On my Windows machine I get the mentioned error message, on a newly installed Ubuntu VM I don't get the message, but the result is the same: The depending import paths will not be updated... |
This is a very unfortunate thing. The only thing that saves is moving one file at a time. Then everything works as expected |
still on android studio 2022.1.1 with macOS 13.1 and flutter 3.3.8 |
Still a problem; macOS, flutter 3.10, studio flamingo. 😢 |
Still a problem; Windows 11, Flutter 3.10, Android Studio Flamingo |
Why is this problem never solved... |
I started using Android Studio for Flutter, then switched to IntelliJ some time after and my experience has been great ever since. Haven't had errors like this, and you also have a Device Manager in IntelliJ for the emulator, so you don't need to open Android Studio. Hope this helps some people |
Seriously why is this still a problem. What's a developer who cant refactor. |
Still facing same problem in |
Seeing this on Windows, Android Studio Iguana 2023.2.1 Canary 1. Almost every file I move now runs into this error and I have to go manually change every reference. Bit annoying :/ |
It's Almost the end of 2023 and this Is still an issue. Facing the Same issue with Android Studio Giraffe | 2022.3.1 and Flutter 3.10.6 |
@jcollins-g @idkq Was this issue mistakenly evaluated as P2 (likely to work on it) and not P1 (will work on it) ? |
facing same issue when it will be solved? |
we can't able to refract the code? |
Sorry for the lack of updates. This issue is unfortunately not just a simple bug fix. The reason for the error is that the IntelliJ plugin sends concurrent requests to the Dart analysis server when multiple items are moved. This is incorrect (since multiple moves could produce conflicting edits) but the Dart analysis server originally only supported moving a single item at a time so there was no real way to fix this besides IntelliJ disabling updating of imports when dragging multiple items (which is what VS Code was doing). I've recently landed some changes to the server to support moving multiple items (and handling where individual moves might product conflicting edits). This is already working in VS Code if you're on bleeding-edge code (because with the LSP protocol changes like this don't require client changes) however there is still some work to do to have IntelliJ use it. |
I wonder if the Dart has been abandoned and is not maintained anymore, because this issue has not been fixed for three years and is still not fixed, which is quite abnormal. |
Dart is both done and not done. We live in a schizo-corporate era of half-made products. Corporations develop products up until the point when it can be reported to shareholders that it's done. What are you're saying? bugs? okay we will look into that, but resources are already diverted to to other projects. |
Although I can understand how it might feel that way based on how long some issues have been open, Dart has not been abandoned. On the contrary, it is actively being maintained and improved. As part of the team that works on the IDE support I can assure you that all of us strive to provide the best product we can for our users. That includes both Google and non-Google contributors. But we, like every team in every company that I've ever worked with, have a finite number of resources. That means that tradeoffs have to be made. We have to choose which features to build and which bugs to fix. Our first consideration is always how we can provide the greatest amount of help to the largest number of users. I'm certainly not claiming that we always make the right tradeoffs, and we are deeply aware of the fact that every feature we don't implement and every bug we don't fix negatively impacts at least some of our users, and sometimes many of them, but making tradeoffs like these is just a reality of life. Anywhere. Whether in large corporations or small companies. I'm sorry for the frustration and lost productivity that this issue has caused, but as @DanTup mentioned above, some progress has been made. We now understand the cause of the bug and we have fixed the issue in VS Code. The remaining work for IntelliJ needs to happen in the IntelliJ Dart plugin. If it hasn't been reported yet, it might be worthwhile opening an issue here: https://youtrack.jetbrains.com/issues/IDEA in order to raise visibility of the issue. |
Same on re-packaging:
Workaround: move file by file, not whole folder |
Exactly, finite resources working on issues in order of priority. but the whole reason this issue at standstill for years is how carelessly it was (de)prioritised. I submit my question again:
|
Same issue here |
In one sense I believe that the issue, at least as far as we're able to work on it, has been completed. From what I can tell by scanning the issue I think that all of the issues are on the IntelliJ side. Has an issue been raised on YouTrack? If so, it might be worth posting that link here so that others can find and upvote it. If I'm misunderstanding the state of things, please let me know. |
I think this is the relevant issue in the JetBrains IntelliJ issue tracker: Currently that issue only has 10 👍s/votes, so it may be worth adding your votes there. |
So this issue is not fixed yet? |
@DanTup |
@TinhHuynh the link still seems to work for me: |
@DanTup |
@liudonghua123 commented on Jul 15, 2020, 6:38 AM UTC:
Thanks for the feedback! If your issue is related to the Flutter framework itself,
please open an issue at
github.com/flutter/flutter.
Steps to Reproduce
lib
from a directory to another directory, both directory are underlib
.Exception when attempting to compute the file changes for the file move: Server error: The
edit.getRefactoringrequest was cancelled."
Please tell us what you were doing and what went wrong
Version info
This issue was moved by stevemessick from flutter/flutter-intellij#4702.
The text was updated successfully, but these errors were encountered: