sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Regular hangs of the analyzer in VSCode on Windows

Open TheLastFlame opened this issue 7 months ago • 4 comments

For the past year, in all my projects, the analyzer has been regularly hanging.

This manifests as:

  1. File saving being blocked (as it uses formatting).

    Image

  2. Broken syntax highlighting, with tooltips displaying outdated information.

    Image

  3. Failure to load object documentation on hover (it shows an endless "Loading...").

To fix this, I have to completely restart the analyzer, after which everything returns to normal for a while, but it invariably breaks again.

Several of my acquaintances are experiencing similar issues. However, after switching to macOS on the same projects, the problem disappears.

I understand that it's impossible to determine the cause with the current information, but I don't know where to find more necessary details. Perhaps there's a way to output detailed logs from the analyzer to capture what it's doing when these problems occur?

TheLastFlame avatar May 10 '25 04:05 TheLastFlame

CC @DanTup

FMorschel avatar May 11 '25 14:05 FMorschel

There are some possibly related issues here:

  • https://github.com/dart-lang/sdk/issues/55281
  • https://github.com/dart-lang/sdk/issues/60335

Significantly, there was a regression in the latest SDK that could cause the analyzer to respond much more slowly - particularly when analyzer plugins (things like custom_lint) are used. I don't know if that's affected you though, as you mention this has been happening for the past year.

The three issues you mentioned are probably all the same cause (that is, the analysis server not responding, or at least being backed up). Do you know if you leave it for a long time, it eventually catches up and starts responding again?

There's a diagnostic report you can export from the analysis server that may be helpful. It would be best exported right after you've seen this issue, although if the server never becomes responsive again, then just exporting it after working for a little (but before the issue occurs) would still be useful:

  • Open the VS Code command palette (F1)
  • Run the Dart: Open Analyzer Diagnostics command
  • Click the Collect Report link to download a json report
  • Verify there's nothing sensitive in the report and attach it here

Thanks!

DanTup avatar May 12 '25 09:05 DanTup

@DanTup, Hi, I'm having trouble downloading the report in Analyser Diagnostic. It just... not working. Image

I ran collect analyser logs. But I'm not sure if there's anything useful there. There's only an error message about the name 'S' (I wrote SuperListView) and my further queries with cancellations.

Dart-Code-Log-2025-05-02 18-03-17.txt

TheLastFlame avatar Jun 10 '25 08:06 TheLastFlame

@TheLastFlame were you able to browser the rest of the Analyzer diagnostic pages and only the report failed? If so, are you able to open developer tools for your browser to see if you can see the raw response (in particular the header and any response body) for the request?

The log file you attached doesn't contain much, but it does show a bunch of requests to the server that were never responded to (although it's not clear to me if the responses would come if left long enough).

Does this happen in all projects, or just a specific project?

One thing that may help is enabling the analyzer instrumentation log (see https://dartcode.org/docs/logging/#analyzer-instrumentation). This file can get quite large and can also contain large parts of your source code (so be careful sharing if you're working on a private project), but it might provide some additional insight into what the server is doing at the time that it becomes unresponsive.

DanTup avatar Jun 10 '25 10:06 DanTup

@DanTup, sorry for not answering the question above However, I want to let you know that based on this comment: https://github.com/dart-lang/sdk/issues/55281#issuecomment-3113836278, I tried disabling realtime protection of Windows Defender. And... it just worked. All the problems with analyzer freezing completely disappeared. Even though my projects were on the Dev disk, Windows Defender still had an effect. This issue probably needs to be renamed.

TheLastFlame avatar Aug 04 '25 21:08 TheLastFlame

Even though my projects were on the Dev disk, Windows Defender still had an effect.

If you didn't move your .analysis-driver folder also, then this could explain that. Most of the files read are in the .dartServer\analysis-driver folder in one of the AppData folders.

Since this seems to be because of Windows Defender, I'm going to close this as a dupe of the upstream issue at https://github.com/dart-lang/sdk/issues/56755.

Thanks!

DanTup avatar Aug 06 '25 15:08 DanTup

I'm going to close this as a dupe of the upstream issue at https://github.com/dart-lang/sdk/issues/56755.

Oops, I didn't realise this was already the SDK tracker and not Dart-Code, so it's not so much upstream as just another issue here.

DanTup avatar Aug 06 '25 15:08 DanTup