sdk
sdk copied to clipboard
VSCode Dart Extension "An error occurred while handling initialized notification"
After upgrading to flutter 3.24.0, the Dart extension on VSCode (1.92.2) stops working often (won't show syntax errors, command + click no longer works, ...). The only way I am able to fix this is by downgrading (I usually go to 3.19.6, and the dart extension will work again). When I upgrade back to 3.24.0 the dart extension will work for some time before no longer working.
The developer tools console when the dart extension stops working on 3.24.0:
The developer tools console when the dart extension is working on 3.19.6:
Potentially related? https://github.com/dart-lang/sdk/issues/48091
dart info
#### General info
- Dart 3.5.0 (stable) (Tue Jul 30 02:17:59 2024 -0700) on "macos_arm64"
- on macos / Version 14.0 (Build 23A344)
- locale is en-US
#### Project info
- sdk constraint: '>=3.0.0'
MacBook Pro, Sonoma 14.0
Let me know if there's any other info I can provide.
Summary: The Dart extension in VS Code (1.92.2) intermittently stops working after upgrading to Flutter 3.24.0. The issue manifests as missing syntax errors, broken command+click functionality, and an "An error occurred while handling initialized notification" message in the developer tools console. Downgrading to Flutter 3.19.6 resolves the issue, but it reoccurs upon upgrading back to 3.24.0.
@DanTup
@erindolson are you able to enable the analyzer instrumentation log for your project (in workspace settings / .vscode/settings.json) temporarily to see whether it records more detailed information about the error (an additional message, or a stack trace)?
Can you also confirm:
- whether this happens in all projects or only a specific project
- whether your path (to the Dart SDK or project) have any special characters in them (I presume not, but you linked to #48091 so it's worth asking)
- what version of the Dart extension for VS Code you're using and whether you're enabled any experimental flags
Thanks for the response
@erindolson are you able to enable the analyzer instrumentation log for your project (in workspace settings /
.vscode/settings.json) temporarily to see whether it records more detailed information about the error (an additional message, or a stack trace)?
instrumentation log: analyzerInstrumentation.txt
Can you also confirm:
- whether this happens in all projects or only a specific project
Downloaded the default flutter app and the dart extension did work - probably something I should've checked before making this bug, sorry about that. I can try an older branch and see what happens.
- whether your path (to the Dart SDK or project) have any special characters in them (I presume not, but you linked to Folder with unusual characters in name causes "An error occurred while handling initialized notification" #48091 so it's worth asking)
Just double checked and I do not as far as I can tell
- what version of the Dart extension for VS Code you're using and whether you're enabled any experimental flags
I am on Dart v3.94.0. No experimental flags.
Thanks - the log file does contain the complete error. It looks like there may be something invalid in your analysis_options.yaml file that's causing it to fail to parse.
You can probably resolve the issue by identifying what's wrong in the analysis_options.yaml file (or posting the contents here if you can't tell), but the server should handle this better. It seems similar (but not the same) as https://github.com/dart-lang/sdk/issues/55594 / https://github.com/dart-lang/sdk/issues/56429.
1724773252168:Ex:An error occurred while handling initialized notification
Null check operator used on a null value
#0 _LintConfig._parseYaml.<anonymous closure>.<anonymous closure>.<anonymous closure> (package::analyzer/src/lint/config.dart::161::48)
#1 CastMap.forEach.<anonymous closure> (dart::_internal/cast.dart::286::8)
#2 _LinkedHashMapMixin.forEach (dart::collection-patch/compact_hash.dart::633::13)
#3 CastMap.forEach (dart::_internal/cast.dart::285::13)
#4 MapView.forEach (dart::collection/maps.dart::347::10)
#5 _LintConfig._parseYaml.<anonymous closure>.<anonymous closure> (package::analyzer/src/lint/config.dart::155::54)
#6 CastMap.forEach.<anonymous closure> (dart::_internal/cast.dart::286::8)
#7 _LinkedHashMapMixin.forEach (dart::collection-patch/compact_hash.dart::633::13)
#8 CastMap.forEach (dart::_internal/cast.dart::285::13)
#9 MapView.forEach (dart::collection/maps.dart::347::10)
#10 _LintConfig._parseYaml.<anonymous closure> (package::analyzer/src/lint/config.dart::144::46)
#11 _HashMap.forEach (dart::collection-patch/collection_patch.dart::153::15)
#12 MapView.forEach (dart::collection/maps.dart::347::10)
#13 _LintConfig._parseYaml (package::analyzer/src/lint/config.dart::117::16)
#14 new LintConfig.parseMap (package::analyzer/src/lint/config.dart::38::62)
#15 parseConfig (package::analyzer/src/lint/config.dart::15::25)
#16 AnalysisOptionsImplExtensions.applyOptions (package::analyzer/src/analysis_options/apply_options.dart::229::18)
#17 ContextBuilderImpl._createOptionsMap (package::analyzer/src/dart/analysis/context_builder.dart::210::15)
#18 ContextBuilderImpl.createContext (package::analyzer/src/dart/analysis/context_builder.dart::135::15)
#19 new AnalysisContextCollectionImpl (package::analyzer/src/dart/analysis/analysis_context_collection.dart::108::36)
Thank you!! I found what was wrong in my analysis_options.yaml.
I had
linter:
rules:
analyzer:
errors:
todo: ignore
Rather than
linter:
rules:
analyzer:
errors:
todo: ignore
Thanks again for all your help and patience!
Great, glad it was an easy fix and thanks for the test case :-)
Since it's a different stack trace to those other errors, let's keep this one open for now to ensure both issues get fixed.