Skip to content

Analysis server crash if analyzer from source doesn't match the sdk version limits - better explanation for the user #5376

Closed

Description

@FMorschel

Describe the bug
When running the analyzer from source, we have a limitation on the version of the SDK which is running it. When you change the version to one that is not compatible, the server fails multiple times and the three toast errors that come up (every time and it keeps trying to make it work without success), only the analyzer toast (that sends you to the analyzer log file now) gives a good-ish (weird phrasing for the versions but I could gather that was something about the versions and the path for my source was displayed there) explanation as to what is going on.

To Reproduce
Steps to reproduce the behavior:

  1. Add a valid value for analyzerPath and sdkPath
  2. Change the sdkPath to a version incompatible with the analyzer

Expected behavior
I'd expect a better exception message. Maybe a fallback:

  • Warn the analyzer is not compatible and run without it.
  • Warn that is not compatible and don't try to restart the server

Activity

  1. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    and removed on Jan 8, 2025
  2. added this to the v3.104.0 milestone on Jan 8, 2025
  3. DanTup commented on Jan 8, 2025

    @DanTup
    Member

    This is probably quite similar to #5328. Both are about what happens when the server crashes/terminates. We might not be able to easily tell that the reason for it "crashing" is because your Dart SDK is "too old" for the source code, but we might at least be able to tell whether the failure was in starting up (eg. it never initialized), and when reporting that we could perhaps hint that this is the case if the server is being run from source.

  4. FMorschel commented on Jan 8, 2025

    @FMorschel
    ContributorAuthor

    The logs for the analyzer did help so maybe we can do something smart to get that info to show the user?

  5. DanTup commented on Jan 8, 2025

    @DanTup
    Member

    Yeah, we have some places that show a button that will show the last x events that were written to a ring log. We should probably do the same here (but doing that requires replacing the stock LSP client error with our own anyway, since its "Go to Output" button is pretty useless in my experience).

  6. FMorschel commented on Jan 15, 2025

    @FMorschel
    ContributorAuthor

    Now I found another problem with enabling it that is not necessarily related to versioning (fixed it with gclient sync so don't need to bother). This is what I mean about the analyzer log being the only useful button from the 4 toasts we get:

    Dart Code extension: 3.103.20250113
    Flutter extension: 3.103.20241202 (activated)
    
    App: Visual Studio Code
    App Host: desktop
    Version: win 1.96.3
    
    
    Logging Categories:
        Analyzer
    
    Wed Jan 15 2025 [14:30:39 GMT-0300 (Horário Padrão de Brasília)] Log file started
    [14:30:39] [Analyzer] [Info] Spawning C:\Users\felip_0vh5fa6\dart\bin\dart.exe with args ["C:/Users/felip_0vh5fa6/Documents/Projects/clones/dart-sdk2/sdk/pkg/analysis_server/bin/server.dart","--lsp","--client-id=VS-Code","--client-version=3.103.20250113","--instrumentation-log-file=C:\\Users\\felip_0vh5fa6\\Documents\\Projects\\logs\\bug\\InstrumentationLog.txt"]
    [14:30:39] [Analyzer] [Info]     PID: 29824
    [14:30:39] [Analyzer] [Info] ==> Content-Length: 6640
    [14:30:39] [Analyzer] [Info] ==> {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":37300,"clientInfo":{"name":"Visual Studio Code","version":"1.96.3"},"locale":"en","rootPath":"c:\\Users\\felip_0vh5fa6\\Documents\\Projects\\dart\\bug","rootUri":"file:///C%3A/Users/felip_0vh5fa6/Documents/Projects/dart/bug","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional","normalizesLineEndings":true,"changeAnnotationSupport":{"groupsOnLabel":true}},"configuration":true,"didChangeWatchedFiles":{"dynamicRegistration":true,"relativePatternSupport":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]},"resolveSupport":{"properties":["location.range"]}},"codeLens":{"refreshSupport":true},"executeCommand":{"dynamicRegistration":true},"didChangeConfiguration":{"dynamicRegistration":true},"workspaceFolders":true,"semanticTokens":{"refreshSupport":true},"fileOperations":{"dynamicRegistration":true,"didCreate":true,"didRename":true,"didDelete":true,"willCreate":true,"willRename":true,"willDelete":true},"inlineValue":{"refreshSupport":true},"inlayHint":{"refreshSupport":true},"diagnostics":{"refreshSupport":true}},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false,"tagSupport":{"valueSet":[1,2]},"codeDescriptionSupport":true,"dataSupport":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]},"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"insertTextModeSuppor…
    [14:31:13] [Analyzer] [Error] ../../../../Documents/Projects/clones/dart-sdk2/sdk/pkg/telemetry/lib/src/pii_regexp.dart:11:8: Error: The 'unnamed-libraries' language feature is disabled for this library.
    Try removing the package language version or setting the language version to 2.19 or higher.
    library;
           ^
    [14:31:14] [Analyzer] [Info] Spawning C:\Users\felip_0vh5fa6\dart\bin\dart.exe with args ["C:/Users/felip_0vh5fa6/Documents/Projects/clones/dart-sdk2/sdk/pkg/analysis_server/bin/server.dart","--lsp","--client-id=VS-Code","--client-version=3.103.20250113","--instrumentation-log-file=C:\\Users\\felip_0vh5fa6\\Documents\\Projects\\logs\\bug\\InstrumentationLog.txt"]
    [14:31:14] [Analyzer] [Info]     PID: 7884
    [14:31:14] [Analyzer] [Info] ==> Content-Length: 6640
    [14:31:14] [Analyzer] [Info] ==> {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":37300,"clientInfo":{"name":"Visual Studio Code","version":"1.96.3"},"locale":"en","rootPath":"c:\\Users\\felip_0vh5fa6\\Documents\\Projects\\dart\\bug","rootUri":"file:///C%3A/Users/felip_0vh5fa6/Documents/Projects/dart/bug","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional","normalizesLineEndings":true,"changeAnnotationSupport":{"groupsOnLabel":true}},"configuration":true,"didChangeWatchedFiles":{"dynamicRegistration":true,"relativePatternSupport":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]},"resolveSupport":{"properties":["location.range"]}},"codeLens":{"refreshSupport":true},"executeCommand":{"dynamicRegistration":true},"didChangeConfiguration":{"dynamicRegistration":true},"workspaceFolders":true,"semanticTokens":{"refreshSupport":true},"fileOperations":{"dynamicRegistration":true,"didCreate":true,"didRename":true,"didDelete":true,"willCreate":true,"willRename":true,"willDelete":true},"inlineValue":{"refreshSupport":true},"inlayHint":{"refreshSupport":true},"diagnostics":{"refreshSupport":true}},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false,"tagSupport":{"valueSet":[1,2]},"codeDescriptionSupport":true,"dataSupport":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]},"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"insertTextModeSuppor…

    image

    [...] its "Go to Output" button is pretty useless in my experience

    Both from the above screenshot take you to the same place that prints the same message multiple times:

    [Error - 14:36:10] Server initialization failed.
      Message: Pending response rejected since connection got disposed
      Code: -32097 
    [Info  - 14:36:10] Connection to server got closed. Server will restart.
    true
    [Error - 14:36:10] Dart Analysis Server client: couldn't create connection to server.
      Message: Pending response rejected since connection got disposed
      Code: -32097 
    [Error - 14:36:10] Restarting server failed
      Message: Pending response rejected since connection got disposed
      Code: -32097 
    [Error - 14:36:50] Server initialization failed.
      Message: Pending response rejected since connection got disposed
      Code: -32097 

    So I agree that this button is useless in this case.

  7. modified the milestones: v3.104.0, v3.106.0 on Jan 28, 2025
  8. DanTup commented on Feb 17, 2025

    @DanTup
    Member

    Looks like we can't do this with the LSP error handler because that only sees stdout.. however, since we're already logging stderr, we can just scan the output and look for well-known errors and pop up a message:

    Image

  9. DanTup commented on Feb 17, 2025

    @DanTup
    Member

    Tweaked it slightly to have "Show Log":

    Image

    Hiding the other error popups will be done as part of #5328.

  10. FMorschel commented on Feb 17, 2025

    @FMorschel
    ContributorAuthor

    Hey, a small request, can you add a button to open the config json? Not sure if you know which one is adding the source path. If you don't, you can ignore this request.

    Thanks a lot, this will help already!

  11. DanTup commented on Feb 20, 2025

    @DanTup
    Member

    We could, although this is currently just using a shared method that handles capturing the log and providing the message. It would require a little more work - I'm not sure how worthwhile it is given there's probably only a single-digit-number of people that ever run the server from source though.

  12. FMorschel commented on Feb 20, 2025

    @FMorschel
    ContributorAuthor

    It's fine then. If we ever have a meaningful ammount of people who use this feature we can reconsider this.

    Thanks a lot!

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

    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions