Skip to content
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

VSCode Dart Extension "An error occurred while handling initialized notification" #56577

Closed
erindolson opened this issue Aug 26, 2024 · 8 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@erindolson
Copy link

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.

Source Dart

The developer tools console when the dart extension stops working on 3.24.0:
image

The developer tools console when the dart extension is working on 3.19.6:
image

Potentially related? #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.

@dart-github-bot
Copy link
Collaborator

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.

@dart-github-bot dart-github-bot added area-intellij Tracking issues for the Dart IntelliJ plugin. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Aug 26, 2024
@bwilkerson
Copy link
Member

@DanTup

@bwilkerson bwilkerson added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. and removed area-intellij Tracking issues for the Dart IntelliJ plugin. labels Aug 26, 2024
@lrhn lrhn removed the triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. label Aug 26, 2024
@scheglov scheglov added the P3 A lower priority bug or feature request label Aug 26, 2024
@DanTup
Copy link
Collaborator

DanTup commented Aug 27, 2024

@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:

@erindolson
Copy link
Author

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.

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.

@DanTup
Copy link
Collaborator

DanTup commented Aug 27, 2024

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 #55594 / #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)

@erindolson
Copy link
Author

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!

@DanTup
Copy link
Collaborator

DanTup commented Aug 27, 2024

Great, glad it was an easy fix and thanks for the test case :-)

@DanTup
Copy link
Collaborator

DanTup commented Aug 27, 2024

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.

@DanTup DanTup reopened this Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

6 participants