Skip to content

Socket error: Bad state: Cannot stop a plugin that is not running #4740

Closed

Description

@ViShadowFiend

Describe the bug
When I open the project in a multi-root worksapce, the dart extension will keep reporting Socket error: Bad state: Cannot stop a plugin that is not running every few seconds. Is there a way to know which plugin this error refers to?

To Reproduce

Expected behavior

Screenshots
image

Please complete the following information:

  • Operating System and version: win11 22H2
  • VS Code version: 1.82.1
  • Dart extension version: 3.72.2
  • Dart/Flutter SDK version: dart 3.0.6, flutter 3.10.16

log
capture analysis server logs

Activity

  1. DanTup commented on Sep 13, 2023

    @DanTup
    Member

    There's not enough information here to tell which plugin is causing the issue. The full stack trace is:

    Socket error
    Bad state: Cannot stop a plugin that is not running.
    Bad state: Cannot stop a plugin that is not running.
    #0      PluginInfo.stop (package:analysis_server/src/plugin/plugin_manager.dart:233:7)
    #1      PluginSession.handleNotification (package:analysis_server/src/plugin/plugin_manager.dart:882:14)
    #2      ServerIsolateChannel.listen.<anonymous closure> (package:analyzer_plugin/src/channel/isolate_channel.dart:234:25)
    #3      _rootRunUnary (dart:async/zone.dart:1415:13)
    #4      _CustomZone.runUnary (dart:async/zone.dart:1308:19)
    #5      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1217:7)
    #6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
    #7      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
    #8      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:776:19)
    #9      _StreamController._add (dart:async/stream_controller.dart:650:7)
    #10     _StreamController.add (dart:async/stream_controller.dart:598:5)
    #11     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)
    

    And this seems to occur when an error occurs in a plugin.

    Could you try enabling the analysis server instrumentation log (which might record the plugin error):

    • Press F1 to open the command palette
    • Run Open Workspace Settings (JSON)
    • Add to the JSON:
      "dart.analyzerInstrumentationLogFile": "logs/analyzer.txt"
    • Reproduce the issue
    • Take a copy of the log and share it here (or email to me at [email protected])
    • Please also include a full copy of your pubspec.yaml/analysis_options.yaml files

    Please be sure to remote anything sensitive from the log/files or reproduce the issue on a non-sensitive project.

  2. added
    awaiting infoRequires more information from the customer to progress
    on Sep 13, 2023
  3. ViShadowFiend commented on Sep 21, 2023

    @ViShadowFiend
    Author

    @DanTup
    hello! I'm sorry I just saw the reply.

    this is log
    logs/analyzer.txt

    this is pubspec.yaml
    pubspec

    this is analysis_options
    analysis_options

  4. DanTup commented on Sep 21, 2023

    @DanTup
    Member

    In the log I see this error being generated:

    1695276601813:PluginNoti: {
    	"event": "plugin.error",
    	"params": {
    		"isFatal": false,
    		"message": "Could not start the VM service: localhost:2935 is already in use.\n",
    		"stackTrace": ""
    	}
    }:file: ///C:/Users/admin/AppData/Local/.dartServer/.plugin_manager/d1d84a9cf669a1228971692ca9be2a97/analyzer_plugin/bin/plugin.dart:
    

    I think this might be happening in the custom_lint plugin. I see a change that may have been intended to fix this at https://github.com/invertase/dart_custom_lint/pull/109/files so I wonder if the issue is there (it's not clear to me if the fix worked or not, as the changelog mentions being reverted). @rrousselGit is this an issue you've had before - do you think this is a custom_lint issue or something the server is doing?

  5. DanTup commented on Sep 21, 2023

    @DanTup
    Member

    I found mention of this same error at invertase/dart_custom_lint#115 (comment) and Remi responded that it was fixed.

    @ViShadowFiend out of interest, are you on the latest version of custom_lint? Could you check which version of custom_lint is recorded in your .dart_tool/package_config.json file (or by running flutter pub deps -s compact | select-string "- custom_lint" from a PowerShell terminal in the project folder)?

  6. rrousselGit commented on Sep 21, 2023

    @rrousselGit

    @DanTup The linked issue is unrelated.

    The topic is this issue is something I've seen happen quite a few times, but I have no clue on where to even get started with regards to what that could be.
    My guess is that it's a VScode thing though. Unless I missed something, I doubt analyzer_plugin enables plugins to show custom snackbars. So it's likely code on your side triggering it.

    My assumption is that it may happen when the analyzer restart, which can happen when editing pubspec.yamls for instance.

  7. DanTup commented on Sep 21, 2023

    @DanTup
    Member

    I'm not sure I understand why they can't be related - the log file shows that a plugin raises the error "Could not start the VM service:: localhost::3094 is already in use." and then there's a fatal error "Failed to start plugins":

    1695276620444:PluginNoti:{"event"::"plugin.error","params"::{"isFatal"::false,"message"::"Could not start the VM service:: localhost::3094 is already in use.\n","stackTrace"::""}}:file::///C::/Users/admin/AppData/Local/.dartServer/.plugin_manager/d1d84a9cf669a1228971692ca9be2a97/analyzer_plugin/bin/plugin.dart::
    1695276620444:PluginNoti:{"event"::"plugin.error","params"::{"isFatal"::true,"message"::"Failed to start plugins","stackTrace"::""}}:file::///C::/Users/admin/AppData/Local/.dartServer/.plugin_manager/d1d84a9cf669a1228971692ca9be2a97/analyzer_plugin/bin/plugin.dart::
    1695276620445:Res:{"jsonrpc"::"2.0","method"::"window/showMessage","params"::{"message"::"Socket error:: Bad state:: Cannot stop a plugin that is not running.","type"::1}}
    

    The server tries to stop the plugin, however that fails - and that error message is surfaced to the user.

    There's likely a bug that the server is either stopping the plugin twice, or it is trying to stop a plugin that didn't start - but presumably this chain of events results from the plugin failing to start?

    (there's also another error in the log about the dart fix check failing, but that happened after all of this)

    My assumption is that it may happen when the analyzer restart, which can happen when editing pubspec.yamls for instance.

    The server doesn't restart, it only rebuilds the analysis contexts. There's nothing in the log (which should include watch events) to suggest this was happening at the time though.

  8. DanTup commented on Sep 21, 2023

    @DanTup
    Member

    @rrousselGit I'm trying to see if I can reproduce this by using the example project from your repo, but I'm struggling to get it to load:

    The package "custom_lint_example_lint" has incompatible version constraints in the project:
    - "./example_lint"
      from "custom_lint_example_app" at ".\..\..\..\..\..\..\Dev\Test Projects\custom_lint_testing\dart_custom_lint\packages\custom_lint\example\pubspec.yaml".
    

    The constraints were Dart 2-3, so I changed them to 3-4, but I still see this error. Pubspec looks like this:

    name: custom_lint_example_app
    version: 0.0.1
    publish_to: none
    
    environment:
      sdk: '>=3.0.0 <4.0.0'
    
    dependencies:
      riverpod: ^2.0.0
    
    dev_dependencies:
      custom_lint:
      custom_lint_example_lint:
        path: ./example_lint
    
    dependency_overrides:
      custom_lint:
        path: ../../custom_lint
      custom_lint_builder:
        path: ../../custom_lint_builder
      custom_lint_core:
        path: ../../custom_lint_core
    

    I don't know if you have access to the specific versions that are wrong, but perhaps this error could include them to make it easier to track down?

    Edit: Nevermind, deleting the plugin-manager folder from .dartServer seems to have fixed it.. I guess something was stale in there.

    Edit2: Spoke too soon, it's still there.

  9. ViShadowFiend commented on Sep 22, 2023

    @ViShadowFiend
    Author

    Sorry, what I provided before was analysis_options of lib

    this is analysis_options of example holder

    include: package:flutter_lints/flutter.yaml
    
    analyzer:
      plugins:
        - custom_lint
      language:
        strict-casts: true
        strict-inference: true
        strict-raw-types: true
      exclude: [ build/**, lib/**.freezed.dart, lib/**.g.dart, lib/**/temp/, lib/pb/**, lib/intl/** ]
    
    linter:
      rules:
        - always_declare_return_types
        - avoid_unused_constructor_parameters
        - cancel_subscriptions
        - cast_nullable_to_non_nullable
        - directives_ordering
        - literal_only_boolean_expressions
        - null_check_on_nullable_type_parameter
        # - omit_local_variable_types
        # - only_throw_errors
        - package_api_docs
        - prefer_const_constructors
        - prefer_interpolation_to_compose_strings
        - test_types_in_equals
        - throw_in_finally
        - unawaited_futures
        - unnecessary_lambdas
        - unnecessary_null_aware_assignments
        - unnecessary_null_checks
        - unnecessary_nullable_for_final_variable_declarations
        - unnecessary_parenthesis
        - unnecessary_statements
        - use_late_for_private_fields_and_variables
    

    my current custom_lint version is 0.4.0 from .dart_tool/package_config.json

    {
          "name": "custom_lint",
          "rootUri": "file:///C:/Users/admin/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/custom_lint-0.4.0",
          "packageUri": "lib/",
          "languageVersion": "2.19"
        },
        {
          "name": "custom_lint_builder",
          "rootUri": "file:///C:/Users/admin/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/custom_lint_builder-0.4.0",
          "packageUri": "lib/",
          "languageVersion": "2.19"
        },
        {
          "name": "custom_lint_core",
          "rootUri": "file:///C:/Users/admin/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/custom_lint_core-0.4.0",
          "packageUri": "lib/",
          "languageVersion": "2.19"
        },
    

    I have tried to remove custom_lint from pubspec and analysis_options, and now the analyzer is running normally

    But the strange thing is that during this period, vscode could not analyze/run normally due to this problem. I switched to android studio, and android studio analyzed/run normally.

  10. DanTup commented on Sep 22, 2023

    @DanTup
    Member

    Looks like your custom_lint is out of date (the current version is 0.5.3). Can you try running flutter pub upgrade to see whether it updates to the latest, and see whether that solves the issue?

    But the strange thing is that during this period, vscode could not analyze/run normally due to this problem. I switched to android studio, and android studio analyzed/run normally.

    I'm not sure why the difference - if I'm able to reproduce this I can try to do some debugging, but so far I wasn't able to get the custom_lint example project to work (#4740 (comment)).

  11. ViShadowFiend commented on Sep 22, 2023

    @ViShadowFiend
    Author

    @DanTup
    I tried to change

      custom_lint:
      riverpod_generator: ^2.2.3
      riverpod_lint: ^1.3.2
    

    to

      custom_lint: ^0.5.3
      riverpod_generator: ^2.3.2
      riverpod_lint: ^2.1.0
    

    Will still report the Socket error: Bad state: Cannot stop a plugin that is not running error

  12. rrousselGit commented on Sep 24, 2023

    @rrousselGit

    @DanTup I have no problem running custom_lint's examples.

    Chances are you shouldn't modify the SDK constraints. If you forgot one place, custom_lint could complain that some projects in your workspace have incompatible SDK constraints.
    It currently doesn't treat Dart <3.0.0 as <4.0.0. So if one project has >2<3 and another has >3<4 then you'll get an error :)

    Anyway I've updated all constraints to <4 just in case. Maybe try again

  13. DanTup commented on Oct 4, 2023

    @DanTup
    Member

    @rrousselGit thanks - it was not being able to use v3 that caused my to change them. Pulling your latest changes seems to work though.

    @ViShadowFiend unfortunately I've been unable to reproduce this with a clean latest clone of the custom_lint repo, opening two copies of the example folder (I copied it to example2 and updated the project names).

    Are you able to share a small (but complete) sample project/folder that is triggering this? Ideally, with all the .dart_tool folders in-tact, and a saved .code-workspace folder that opens things exactly as reproduces the issue for you.

    Thanks!

  14. ViShadowFiend commented on Oct 4, 2023

    @ViShadowFiend
    Author

    @DanTup
    I create a repo here: https://github.com/ViShadowFiend/dartcode_error
    But now, I can't reproduce the Socket error: Bad state: Cannot stop a plugin that is not running error, Now there are 3 more new errors.

    // Unable to edit document because the file was not previously opened: D:\coding\socketerror\lib_ble\example\lib\main.dart
    
    // Socket error: Concurrent modification during iteration: _Map len:2.
    
    // An unrecoverable error occurred and the server cannot process messages
    

    Maybe it's because I used another computer or new Dart extension this time

    • Operating System and version: win10 10.0.19045.3208
    • VS Code version: 1.82.2
    • Dart extension version: 3.74.0
    • Dart/Flutter SDK version: dart 3.0.6, flutter 3.10.6
  15. 40 remaining items

  16. DanTup commented on Nov 27, 2023

    @DanTup
    Member

    Thanks for the updated log. I can see a few weird things in there... one is that analysis is failing for a file (this is usually a bug in parsing or something):

    *** 1701018908962:Res:{"id"::36,"jsonrpc"::"2.0","error"::{"code"::-32013,"data"::"D::\coding\dartcode_error_f\lib_ble\example\lib\app.dart","message"::"Analysis failed for file"}}

    And next I see a file closed and re-opened before we send this error:

    1701018910559:Req:{"jsonrpc"::"2.0","method"::"textDocument/didClose","params"::{"textDocument"::{"uri"::"file::///D%3A/coding/dartcode_error_f/lib_ble/example/lib/app.dart"}},"clientRequestTime"::1701018909873}
        1701018910563:Req:{"jsonrpc"::"2.0","method"::"textDocument/didOpen","params"::{"textDocument"::{"uri"::"file::///D%3A/coding/dartcode_error_f/lib_ble/example/lib/app.dart","languageId"::"dart","version"::5,"text"::"import 'package::flutter/material.dart';\r\nimport 'package::hooks_riverpod/hooks_riverpod.dart';\r\n\r\nclass App extends HookConsumerWidget with WidgetsBindingObserver {\r\n  const App({Key? key}) :: super(key:: key);\r\n\r\n  @override\r\n  Widget build(BuildContext context, WidgetRef ref) {\r\n    return MaterialApp(\r\n      color:: Colors.green,\r\n      home:: Scaffold(\r\n        appBar:: AppBar(\r\n          title:: const Text(\"test\"),\r\n          centerTitle:: true,\r\n          backgroundColor:: Colors.green,\r\n        ),\r\n        body:: const SingleChildScrollView(\r\n            child:: Column(\r\n              crossAxisAlignment:: CrossAxisAlignment.stretch,\r\n              children:: [\r\n                Text(\"1\"),\r\n                Text(\"2\"),\r\n                Text(\"3\"),\r\n                Text('3'),\r\n                Text('4'),\r\n                Text(\"5\"),\r\n                Text('6'),\r\n                Text(\"7\"),\r\n                Text('8'),\r\n                Text('9'),\r\n                Text(\"10\"),\r\n                Tex\r\n              ],\r\n            ),\r\n          ),\r\n\r\n      ),\r\n    );\r\n  }\r\n}\r\n"}},"clientRequestTime"::1701018909875}
        1701018912112:Req:{"jsonrpc"::"2.0","method"::"textDocument/didChange","params"::{"textDocument"::{"uri"::"file::///D%3A/coding/dartcode_error_f/lib_ble/example/lib/app.dart","version"::6},"contentChanges"::[{"range"::{"start"::{"line"::31,"character"::16},"end"::{"line"::31,"character"::19}},"rangeLength"::3,"text"::"Text(data)"}]},"clientRequestTime"::1701018912108}
        1701018912113:Res:{"jsonrpc"::"2.0","method"::"window/showMessage","params"::{"message"::"Unable to edit document because the file was not previously opened:: D::\\coding\\dartcode_error_f\\lib_ble\\example\\lib\\app.dart","type"::1}}   
    

    This also seems incorrect, because our error message says the file is not open, but according to the log it clearly is.

    I'll see what I can find, thanks!

  17. DanTup commented on Nov 28, 2023

    @DanTup
    Member

    @ViShadowFiend I'm not having much look reproducing these issues. Can you confirm exactly what code you started with (including any changes made from what's in the repository)? I noticed that custom_lint is commented out in the repo but your log shows that the plugin is enabled.

    From the logs, it looks like the first error (analysis failed) when you typed a T in the file example\lib\app.dart here:

    image

    I tried:

    • switching to Flutter 3.16.0
    • clean clone of the project
    • Allow VS Code to run pub get in all projects
    • I noticed it got newer versions of some packages, so I hard-coded all the versions to match what was in your package_config.json and ran it again until all versions in package_config matched the versions you had committed
    • enabled the custom_lint plugin in example/analysis_options.yaml
    • opened your .code-workspace file and made the change above in example/lib/app.dart (and tried saving)

    Unfortunately none of the issues in your log occurred in mine. If you can provide precise steps from cloning the repository (including any modifications to any files) that might help me reproduce. Thanks!

  18. ViShadowFiend commented on Nov 28, 2023

    @ViShadowFiend
    Author

    @DanTup

    I just added two new commits, please check them again.
    Let me describe the reproduction process

    1. Clean clone from the second to last commit
    2. Open vLibs.code-workspace
    3. A message pops up in the lower right corner of vscode, confirm to run flutter pub get
    4. Enable plugins - custom_lint, save analysis_options.yaml file
    5. Open lib_ble/example/lib/app.dart and edit, error occurs

    The last commit has custom_lint enabled, and the dartcode_error/lib_ble/logs
    /analyzer.txt.1 file contains the Unable to edit document because the file was not previously opened error message

  19. DanTup commented on Nov 28, 2023

    @DanTup
    Member

    Unfortunately it still doesn't reproduce. Is it possible you could send me a copy of the following files?

    From C:\Users\Vi\AppData\Local\.dartServer\.plugin_manager\ada8d5e66ea6c5757d0231fed119e521:

    • analyzer_plugin\.dart_tool\package_config.json
    • analyzer_plugin\pubspec.lock
    • analyzer_plugin\pubspec.yaml

    While I'm on the same versions of all packages in your project, perhaps there's a difference in the versions that were resolved for the plugins. I'm not sure why that would cause this kind of failure, but perhaps by eliminating more variables I'll be able to trigger it here.

    Thanks!

  20. ViShadowFiend commented on Nov 28, 2023

    @ViShadowFiend
    Author

    @DanTup

    analyzer_plugin\.dart_tool\package_config.json

    {
      "configVersion": 2,
      "packages": [
        {
          "name": "_fe_analyzer_shared",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/_fe_analyzer_shared-65.0.0",
          "packageUri": "lib/",
          "languageVersion": "3.0"
        },
        {
          "name": "analyzer",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/analyzer-6.3.0",
          "packageUri": "lib/",
          "languageVersion": "3.0"
        },
        {
          "name": "analyzer_plugin",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/analyzer_plugin-0.11.3",
          "packageUri": "lib/",
          "languageVersion": "3.0"
        },
        {
          "name": "args",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/args-2.4.2",
          "packageUri": "lib/",
          "languageVersion": "2.19"
        },
        {
          "name": "async",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/async-2.11.0",
          "packageUri": "lib/",
          "languageVersion": "2.18"
        },
        {
          "name": "checked_yaml",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/checked_yaml-2.0.3",
          "packageUri": "lib/",
          "languageVersion": "2.19"
        },
        {
          "name": "ci",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/ci-0.1.0",
          "packageUri": "lib/",
          "languageVersion": "2.12"
        },
        {
          "name": "cli_util",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/cli_util-0.4.0",
          "packageUri": "lib/",
          "languageVersion": "2.19"
        },
        {
          "name": "collection",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/collection-1.18.0",
          "packageUri": "lib/",
          "languageVersion": "2.18"
        },
        {
          "name": "convert",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/convert-3.1.1",
          "packageUri": "lib/",
          "languageVersion": "2.18"
        },
        {
          "name": "crypto",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/crypto-3.0.3",
          "packageUri": "lib/",
          "languageVersion": "2.19"
        },
        {
          "name": "custom_lint",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/custom_lint-0.5.7",
          "packageUri": "lib/",
          "languageVersion": "3.0"
        },
        {
          "name": "dart_style",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/dart_style-2.3.4",
          "packageUri": "lib/",
          "languageVersion": "3.0"
        },
        {
          "name": "file",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/file-7.0.0",
          "packageUri": "lib/",
          "languageVersion": "3.0"
        },
        {
          "name": "freezed_annotation",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/freezed_annotation-2.4.1",
          "packageUri": "lib/",
          "languageVersion": "2.17"
        },
        {
          "name": "glob",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/glob-2.1.2",
          "packageUri": "lib/",
          "languageVersion": "2.19"
        },
        {
          "name": "json_annotation",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/json_annotation-4.8.1",
          "packageUri": "lib/",
          "languageVersion": "2.19"
        },
        {
          "name": "meta",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/meta-1.11.0",
          "packageUri": "lib/",
          "languageVersion": "2.12"
        },
        {
          "name": "package_config",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/package_config-2.1.0",
          "packageUri": "lib/",
          "languageVersion": "2.12"
        },
        {
          "name": "path",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/path-1.8.3",
          "packageUri": "lib/",
          "languageVersion": "2.12"
        },
        {
          "name": "pub_semver",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/pub_semver-2.1.4",
          "packageUri": "lib/",
          "languageVersion": "2.17"
        },
        {
          "name": "pubspec_parse",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/pubspec_parse-1.2.3",
          "packageUri": "lib/",
          "languageVersion": "2.18"
        },
        {
          "name": "rxdart",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/rxdart-0.27.7",
          "packageUri": "lib/",
          "languageVersion": "2.12"
        },
        {
          "name": "source_span",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/source_span-1.10.0",
          "packageUri": "lib/",
          "languageVersion": "2.18"
        },
        {
          "name": "sprintf",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/sprintf-7.0.0",
          "packageUri": "lib/",
          "languageVersion": "2.12"
        },
        {
          "name": "string_scanner",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/string_scanner-1.2.0",
          "packageUri": "lib/",
          "languageVersion": "2.18"
        },
        {
          "name": "term_glyph",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/term_glyph-1.2.1",
          "packageUri": "lib/",
          "languageVersion": "2.12"
        },
        {
          "name": "typed_data",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/typed_data-1.3.2",
          "packageUri": "lib/",
          "languageVersion": "2.17"
        },
        {
          "name": "uuid",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/uuid-4.2.1",
          "packageUri": "lib/",
          "languageVersion": "2.14"
        },
        {
          "name": "watcher",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/watcher-1.1.0",
          "packageUri": "lib/",
          "languageVersion": "3.0"
        },
        {
          "name": "yaml",
          "rootUri": "file:///C:/Users/Vi/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/yaml-3.1.2",
          "packageUri": "lib/",
          "languageVersion": "2.19"
        },
        {
          "name": "custom_lint_analyzer_plugin_loader",
          "rootUri": "../",
          "packageUri": "lib/",
          "languageVersion": "2.14"
        }
      ],
      "generated": "2023-11-28T13:10:56.819369Z",
      "generator": "pub",
      "generatorVersion": "3.2.0"
    }
    
    

    analyzer_plugin\pubspec.lock

    # Generated by pub
    # See https://dart.dev/tools/pub/glossary#lockfile
    packages:
      _fe_analyzer_shared:
        dependency: transitive
        description:
          name: _fe_analyzer_shared
          sha256: "36a321c3d2cbe01cbcb3540a87b8843846e0206df3e691fa7b23e19e78de6d49"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "65.0.0"
      analyzer:
        dependency: transitive
        description:
          name: analyzer
          sha256: dfe03b90ec022450e22513b5e5ca1f01c0c01de9c3fba2f7fd233cb57a6b9a07
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "6.3.0"
      analyzer_plugin:
        dependency: transitive
        description:
          name: analyzer_plugin
          sha256: "9661b30b13a685efaee9f02e5d01ed9f2b423bd889d28a304d02d704aee69161"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "0.11.3"
      args:
        dependency: transitive
        description:
          name: args
          sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "2.4.2"
      async:
        dependency: transitive
        description:
          name: async
          sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "2.11.0"
      checked_yaml:
        dependency: transitive
        description:
          name: checked_yaml
          sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "2.0.3"
      ci:
        dependency: transitive
        description:
          name: ci
          sha256: "145d095ce05cddac4d797a158bc4cf3b6016d1fe63d8c3d2fbd7212590adca13"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "0.1.0"
      cli_util:
        dependency: transitive
        description:
          name: cli_util
          sha256: b8db3080e59b2503ca9e7922c3df2072cf13992354d5e944074ffa836fba43b7
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "0.4.0"
      collection:
        dependency: transitive
        description:
          name: collection
          sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "1.18.0"
      convert:
        dependency: transitive
        description:
          name: convert
          sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "3.1.1"
      crypto:
        dependency: transitive
        description:
          name: crypto
          sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "3.0.3"
      custom_lint:
        dependency: "direct main"
        description:
          name: custom_lint
          sha256: "198ec6b8e084d22f508a76556c9afcfb71706ad3f42b083fe0ee923351a96d90"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "0.5.7"
      dart_style:
        dependency: transitive
        description:
          name: dart_style
          sha256: "40ae61a5d43feea6d24bd22c0537a6629db858963b99b4bc1c3db80676f32368"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "2.3.4"
      file:
        dependency: transitive
        description:
          name: file
          sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "7.0.0"
      freezed_annotation:
        dependency: transitive
        description:
          name: freezed_annotation
          sha256: c3fd9336eb55a38cc1bbd79ab17573113a8deccd0ecbbf926cca3c62803b5c2d
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "2.4.1"
      glob:
        dependency: transitive
        description:
          name: glob
          sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "2.1.2"
      json_annotation:
        dependency: transitive
        description:
          name: json_annotation
          sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "4.8.1"
      meta:
        dependency: transitive
        description:
          name: meta
          sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "1.11.0"
      package_config:
        dependency: transitive
        description:
          name: package_config
          sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "2.1.0"
      path:
        dependency: transitive
        description:
          name: path
          sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "1.8.3"
      pub_semver:
        dependency: transitive
        description:
          name: pub_semver
          sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "2.1.4"
      pubspec_parse:
        dependency: transitive
        description:
          name: pubspec_parse
          sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "1.2.3"
      rxdart:
        dependency: transitive
        description:
          name: rxdart
          sha256: "0c7c0cedd93788d996e33041ffecda924cc54389199cde4e6a34b440f50044cb"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "0.27.7"
      source_span:
        dependency: transitive
        description:
          name: source_span
          sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "1.10.0"
      sprintf:
        dependency: transitive
        description:
          name: sprintf
          sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "7.0.0"
      string_scanner:
        dependency: transitive
        description:
          name: string_scanner
          sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "1.2.0"
      term_glyph:
        dependency: transitive
        description:
          name: term_glyph
          sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "1.2.1"
      typed_data:
        dependency: transitive
        description:
          name: typed_data
          sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "1.3.2"
      uuid:
        dependency: transitive
        description:
          name: uuid
          sha256: df5a4d8f22ee4ccd77f8839ac7cb274ebc11ef9adcce8b92be14b797fe889921
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "4.2.1"
      watcher:
        dependency: transitive
        description:
          name: watcher
          sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "1.1.0"
      yaml:
        dependency: transitive
        description:
          name: yaml
          sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
          url: "https://pub.flutter-io.cn"
        source: hosted
        version: "3.1.2"
    sdks:
      dart: ">=3.0.0 <4.0.0"
    
    

    analyzer_plugin\pubspec.yaml

    name: custom_lint_analyzer_plugin_loader
    description: This pubspec determines the version of the analyzer plugin to load.
    version: 0.5.7
    publish_to: none
    
    environment:
      sdk: ">=2.14.0 <4.0.0"
    
    dependencies:
      custom_lint: 0.5.7
    
    # TODO: If you want to contribute to custom_lint, add a pubspec_overrides.yaml file
    # in this folder, containing the following:
    # dependency_overrides:
    #   custom_lint:
    #     path: /absolute/path/to/custom_lint/folder
    
    

  21. DanTup commented on Nov 28, 2023

    @DanTup
    Member

    @ViShadowFiend thanks! Turns out those versions all matched mine so it wasn't that. I've still not been able to repro (I even tried replaying your log against a local server), however when reading through the logs I noticed that the plugin was being started/shutdown when I wouldn't except (when you closed a file).

    I noticed you have the "dart.onlyAnalyzeProjectsWithOpenFiles" setting set to true in your User Settings. Can you try disabling that and reloading VS Code and see whether you can still reproduce without that setting? I can't repro even with that set, but it'd be interesting to know whether it's contributing to the issue.

    (I'm also curious what led you to enable that setting - it was mostly there for non-VS Code LSP clients that don't have a good concept of an open workspace).

    Thanks!

  22. DanTup commented on Nov 28, 2023

    @DanTup
    Member

    Actually, I was able to reproduce the issue with that setting enabled manually (probably the timing when I replayed the log was not the same). I should be able to track it down from here - thank you for the help with the logs!

  23. DanTup commented on Nov 28, 2023

    @DanTup
    Member

    I raised #4862 for the "Unable to edit document because the file was not previously opened" issue specifically (because I'm unsure if there are still other errors here), but here's a summary:

    The issue is a bug in handling of closed files. There is an await that meant if a client closed and re-opened a file very close together, the close could be processed after the open, leaving the file in a "closed" state (which produces this error on the next change).

    It isn't directly related to plugins or onlyAnalyzeProjectsWithOpenFiles, however using plugins can result in us re-registering capabilities with the client when analysis roots change (which results in VS Code's LSP client closing and re-opening all files since those events are tied to the capabilities) and using onlyAnalyzeProjectsWithOpenFiles causes additional work when files are opening/closing which makes it more likely for the bad await to cause the work to be re-ordered.

    I have a fix open at https://dart-review.googlesource.com/c/sdk/+/338660 but since it'll only ship in a future SDK release my recommendation is to disable onlyAnalyzeProjectsWithOpenFiles as a workaround (I'd generally recommend not using that at all, but if you do feel you need it for some projects, set it only on those projects rather than in your global user settings).

  24. rrousselGit commented on Nov 28, 2023

    @rrousselGit

    On the topic of errors, should VScode show errors from analyzer_plugins in a snackbar?

  25. DanTup commented on Nov 28, 2023

    @DanTup
    Member

    On the topic of errors, should VScode show errors from analyzer_plugins in a snackbar?

    I'm not sure, though I suspect the answer might depend on the kind/frequency of errors. If a plugin is completely broken (throwing exceptions) I think there should be a way for a user to know this, but we never want to be in the situation where a plugin is throwing errors on every keystroke and we're spewing out notifications (something I've seen in Dart-Code in the past without plugins and it looks terrible).

    Something we don't use yet but might be an idea place for errors like that (and other non-critical but severe errors from the server) in VS Code is the language status area. Setting an error/warning status would show an indicator on the "{} Dart" area of the status bar, and opening the flyout would show a little more info (with a link to the analyzer diagnostics page with more details).

    I probably don't have a good handle on the frequency (or severity) of the errors plugins generate, but if the current behaviour doesn't seem ideal, perhaps it's worth opening an issue in the SDK for discussion (it's probably not worth making any changes prior to the work @srawlins is doing though).

  26. ViShadowFiend commented on Nov 29, 2023

    @ViShadowFiend
    Author

    I'm glad you finally reproduced the error! Thank you very much for your patient replies!

    I just disabled the dart.onlyAnalyzeProjectsWithOpenFiles option, and indeed there are no more errors, everything is fine!

    As for why I enabled this option, I remember it was because the dart analyzer analyzes the dart files of the entire project, which is so slow that I have to wait for a long time every time I open the project.

    Thanks again!

  27. DanTup commented on Nov 29, 2023

    @DanTup
    Member

    As for why I enabled this option, I remember it was because the dart analyzer analyzes the dart files of the entire project, which is so slow that I have to wait for a long time every time I open the project.

    With this setting, the analyzer will still analyze whole projects - but only those projects that have open files. If you're using something like a command line editor which might set a very large workspace folder, this can reduce the analysis done. For something like VS Code, you'll incur the cost of destroying and re-creating analysis contexts as you close/open files though, so you might find that analysis is less responsive immediately after opening the "first" file in a project each time.

    If you do feel you need to use it for some projects (though I'd still generally advise against it - and file issues if you feel the performance is bad with some details about the size of your workspace), I would suggesting setting it only in their workspaces (and not your user settings).

  28. removed
    awaiting infoRequires more information from the customer to progress
    on Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions