-
Notifications
You must be signed in to change notification settings - Fork 1.7k
depend_on_referenced_packages requires analysis server restart to update #58425
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
Comments
Actually this looks like it might happen in normal workspaces as well, at least sometimes. |
The way it supposed to work is that when a file that affects analysis environment (URI resolution, packages, etc - anything except just dart files) changes, we nuke the analysis context collection. This includes So, I would expect that this already works. Might be related to #45996 |
In an offline conversation we think that it might be related to some cached values in the Workspace / WorkspacePackage classes that isn't getting flushed when the |
Yes, after doing some digging I am very confused as to what is going on. As far as I can tell we should be nuking the entire analysis context collection. And that does from what I can tell include the workspace objects. Possibly it is not recognizing the pubspec.yaml file update properly? |
Well, it should be easy to check - log As far as I can see, we don't have a static cache in |
Note that I can also consistently reproduce this now in any package by doing the following:
The lint will not trigger once you do this, when it should. I think that possibly we stop watching the pubspec after the first update? You can similarly do the following:
In this case the lint won't go away like it should |
OK, I think we do have a caching issue. With this lint the set of errors depends on the content of the |
Bug: https://github.com/dart-lang/linter/issues/2694 Change-Id: I239863703c70c6bd810be6847606e5fc6695073a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202265 Reviewed-by: Samuel Rawlins <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
With @scheglov's fix, I think we can close this? |
Yes, I think so. |
/fyi @jakemac53 |
Unfortunately this still appears very flaky to me :( |
Works for me, I tested it in Dart SDK repo, by commenting out and restoring
|
I have tried again today, and rebuilt the sdk as of this morning (including a gclient sync). But I still don't see it updating. I tried doing a similar flow (commenting out a dependency and then uncommenting it). I am using VsCode and not intellij, not sure if that makes a difference? |
Ok I have a bit more info - this appears to happen when I have multiple workspaces open and not just a single package. I am not sure how that might affect things... Or more specifically it might only be happening when I also have a package:build workspace open? |
Further clarification, this appears to be happening only when opening the root of a mono_repo - in other words a directory containing multiple packages in subdirectories. The example I am testing with is the build repo (http://github.com/dart-lang/build). If I open the root of that repo then pubspec edits are not respected without a restart. If I open a subdirectory then things work as expected. Note that in general pubspecs may be recursively nested as well (this is common in flutter example dirs for instance). |
Another note here - as soon as you add a mono repo to your workspace, updates to the pubspecs in other, non-monorepo dirs also stop working. |
Hm... I can reproduce it, sometimes. My best theory for now is that it is a race condition between reading the file content following changes. The fact that we may read the file more than once means that we might compute the salt with one content, and parse it with another. I will try to fix this issue. |
https://dart-review.googlesource.com/c/sdk/+/202726 should make results consistent. But I think that we still have an issue here - I still can see that we don't react to some changes to
|
This makes it less probably that we will get inconsistent results, such as computing the salt with one file content, but then read a different content for parsing and reporting lints. But I think there there is still something not quite correct with deciding that there was a change to pubspec.yaml, we might miss some events. Bug: https://github.com/dart-lang/linter/issues/2694 Change-Id: Ied76dc2f6c1203d3eed68e5220196d91c6d8e717 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202726 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
@scheglov do you think this is something we can reasonably resolve? I am still very regularly running into this issue so I think it would preclude any lint that requires reacting to pubspec.yaml files from being included in the core set as the usability is not up to the bar for something we enforce on pub. If we need to keep that in mind as a general rule that is fine, but I would like to reach a decision one way or the other :). |
I tried to start watching the included folders on the file system before starting to build analysis context, but I just don't get any events from My next idea is to check pertinent |
Ok, if you intend to still work on this a bit more I am happy to wait - the urgency isn't super high here. I just want to avoid a forever stale issue as this is a blocker for another decision (whether to include depend_on_referenced_packages in the core lint set). So basically all I ask is that if you reach a point where you don't think there is anything else reasonable to do on the analyzer side of things, that we update this issue as such and close it :). |
I will also open a question issue for |
For me this seems to work reliably for fast |
Bug: https://github.com/dart-lang/linter/issues/2694 Change-Id: I13cae115e48ae794e0751b6099f864ca9d202cdc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203821 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
I just rebuilt as of this morning and at least for the build repo I am still consistently not seeing any updates after the first update to a pubspec. A regular, non-mono repo seems to be working consistently though. |
Fwiw I had the same thing happen with the analysis_options.yaml file for me today. First edit to it worked and then no subsequent edits did anything until I restarted the analysis server. |
We have now checks for changes that happen during analysis contents creation to "No subsequent changes" sounds potentially as something different, I need to check. |
This is generally the behavior I am seeing now for pubspec.yaml as well. The very first edit does work, but no future edits work. |
Are the future edits putting the file content back to the original state, by chance? |
Yes that is generally what I am testing (comment/uncomment a line to add/remove a dependency) |
Does it catch the second change when it doesn't return it to its original state? I could imagine the behavior you're seeing if we're not updating the content in the cache after the first change. That is, we notice the change by comparing the cached content with the actual content and re-analyze, but the next time we get new content we compare it against the unchanged cached version and think that there hasn't been a change. |
I cannot reproduce this.
|
When I follow those same instructions only Step 1 gives the same behavior... 😕 . Nothing else works for me after that point. I just rebuilt my sdk as of this morning. |
@scheglov can you try with vscode? I don't see why it would make a difference but maybe somehow it does? |
I turned on some logging and I confirm that I do see update events for the pubspec in the logs, I sent Konstantin the full logs offline so hopefully that helps. |
I don't have VS Code installed, it will take some time to get there. |
Did you save |
Yes, I did save. If that message is not what it prints for file events (I just assumed it was) then I was probably wrong and it is indeed still not seeing the file events? |
In order to see watch events you need to provide Then you will see something like:
Note |
Is this still happening @jakemac53? Noticed this is three years old now. |
I couldn't reproduce it just now so I think its resolved |
When using the depend_on_referenced_packages linte, you have to restart the analysis server after editing your pubspec in order to get the lint to go away. This only appears to happen after the first update to the pubspec though (the very first modification is respected, usually).
The text was updated successfully, but these errors were encountered: