Dart-Code: Dart formatter Keeps running endlessly
Issue Type: Bug
It’s random. At times when you save dart code. Dart formatter starts running and do not stops for several minutes (around 5 minutes minimum). I have to cancel it and save again and same thing happens. Only solution is restart VScode or sometimes restart the PC.
Extension version: 3.21.1 VS Code version: Code 1.55.1 (08a217c4d27a02a5bcde898fd7981bda5b49391b, 2021-04-07T15:06:02.360Z) OS version: Windows_NT x64 10.0.19041
System Info
Item | Value |
---|---|
CPUs | Intel® Core™ i7-8550U CPU @ 1.80GHz (8 x 1992) |
GPU Status | 2d_canvas: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on oop_rasterization: enabled opengl: enabled_on protected_video_decode: enabled rasterization: enabled skia_renderer: enabled_on video_decode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled |
Load (avg) | undefined |
Memory (System) | 7.89GB (1.46GB free) |
Process Argv | –crash-reporter-id fd9ee2dd-443c-41b6-b90c-1cb615a784b2 |
Screen Reader | no |
VM | 0% |
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstry244:30276681
pythonvsdeb440:30248342
pythonvsded773:30248341
pythonvspyt875:30259475
pythontb:30283811
openwsldoc:30282072
vspre833cf:30267465
pythonptprofiler:30281270
vshan820cf:30276953
pythondataviewer:30285071
vscus158:30286553
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 59
- Comments: 89 (35 by maintainers)
Flutter 2.2.2 has just been released to the stable channel which includes a fix for one of the issues mentioned above (where on macOS the analysis server would stop responding after certain types of files are modified).
Please upgrade to Flutter 2.2.2 and restart all instances of VS Code. If you’re still seeing this issue on Flutter 2.2.2 or later, please do let me know. Thanks!
I don’t know what is causing it, but all I see is “Saving ‘http.dart’: Running ‘Dart’ Formatter (configure)”. and it doesn’t stop. Started with the latest Flutter upgrade. Have to restart vscode everytime and try again, works for one or two saves. Is there anything I can provide to help solve this issue? Serious workflow problem.
Flutter 2.2.0 • channel stable • https://github.com/flutter/flutter.git Framework • revision b22742018b (10 days ago) • 2021-05-14 19:12:57 -0700 Engine • revision a9d88a4d18 Tools • Dart 2.13.0
happening to my and half my team on flutter 2.2 this is very frustrating. none of the fixes above worked.
I have deleted
editor.codeActionsOnSave": null
insettings.json
and my problem fixed.null
not acceptable.@mellowcello77 a log could be very helpful:
dart.analyzerInstrumentationLogFile
to a file path for logging (either absolute, or relative like"logs/analyzer.txt"
which will go in the project folder)The log file may contain parts of your source code so if it’s something you can’t share, please open the log file and look for the last few occurrences of
:Res:
near the bottom of the file which should show what request(s) the server last responded to. I’m interested to know what are the few requests (:Req
) around that time that were not responded to.If you can repro on a project without sensitive code, feel free to just attach (or email to me at logs@dartcode.org) the lines starting a handful above the last server response. Thanks!
@mellowcello77 got it - in that case I’m fairly sure it’s the same issue mentioned above. When you run a Flutter build if it modifies certain types of files (usually in the
.dart_tool
folder) the analyzer rebuilds some internal state that involves removing an old file watcher and adding a new one. That seems to cause an issue (I think a deadlock) that prevented the server from responding to any further requests.If anyone sees this issue not on macOS or not after running a Flutter build/debug session and can provide a log, that would be useful. If it’s macOS after running a debug build, I think it’s probably covered by the existing fix.
I was facing the same issue and noticed it would only happen when my internet connection was slow or down. For me, disabling analytics solved the problem:
Having the same issues with the following -
Flutter 2.8.0 • channel stable • https://github.com/flutter/flutter.git Framework • revision cf44000065 (6 days ago) • 2021-12-08 14:06:50 -0800 Engine • revision 40a99c5951 Tools • Dart 2.15.0
This helped me in VS Code:
Uninstall the Flutter extension and Dart extensions then reinstall them. Restart your VS Code
It seems to happen a lot less on Flutter 2.0.6. Temporary solution that worked for me:
git checkout 2.0.6
;flutter doctor
to download binaries;@netgfx
I’m not certain, but I suspect it’s probably not the formatter here - I think the server is not responding correctly and then the format requests jut gets stuck (I think it was coincidence that I triggered something similar behaviour by actually having something that formatted slowly).
If this seems to happen after you’re just run a debug session and the analysis server appears to never recover, then it could be related to https://github.com/dart-lang/sdk/issues/45996 (which my or may not be specific to macOS), though I don’t fully understand what’s happening there yet.
@DanTup Restarting vscode fixed it. My log setting is active, I’ll repost from the next. I didn’t make any changes for
dart.previewLsp
in the initial setting. I think this event happens after this situation that run real ios device or simulator mixed.Upgrading to flutter 2.2.2 did fix this for me on an M1 mac
@DanTup the error persisted to me, unfortunately.
For the record, the Dart formatter issue is fixed for me as of 2.2.2 (MacOS Big Sur 11.4 VS Code 1.57.0)
This comment: https://github.com/Dart-Code/Dart-Code/issues/3270#issuecomment-857349415
I uninstalled Flutter, Dart plugin in Visual Studio Code, and then restart IDE, it works magically! But just restarting the IDE does not help, you have to reinstall frameworks too!
Unfortunately I’m having the same issue, but on macOS. Might just leave my SDK versions and OS here, maybe it’s helpful 😃 thx for investigating on that!
macOS 11.4
Potentially relevant: https://github.com/microsoft/vscode/issues/107103#issuecomment-731664821
I spoke too soon - issue back again. I have captured it on the logs and emailed the file to you at the above email address.
It seems to take out my whole dart analyzer too. I lose all my automatic code completion and it also won’t detect warnings/errors in the VSCode problems tab.
Only occurs when I’m debugging on a physical device or emulator.
This fixed it for me. Having “null” raised a warning that an object was expected. Make sure to restart VSCode after.
even with no more than 300 lines of flutter code, no conditionals. But system overall low memory (less than 1Gb unallocated) still causes this issue on a daily basis. Could it be that the formatting process requires some system resources to be available at the forefront (even if it doesn’t utilize them completely)?