You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Analysis server crash if analyzer from source doesn't match the sdk version limits - better explanation for the user #5376
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:
Add a valid value for analyzerPath and sdkPath
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
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.
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).
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.20250113Flutter extension: 3.103.20241202 (activated)App: Visual Studio CodeApp Host: desktopVersion: win 1.96.3Logging Categories: AnalyzerWed 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…
[...] 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.
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:
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.
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.
Activity
DanTup commentedon Jan 8, 2025
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.
FMorschel commentedon Jan 8, 2025
The logs for the analyzer did help so maybe we can do something smart to get that info to show the user?
DanTup commentedon Jan 8, 2025
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).
FMorschel commentedon Jan 15, 2025
Now I found another problem with enabling it that is not necessarily related to versioning (fixed it with
gclient syncso 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:Both from the above screenshot take you to the same place that prints the same message multiple times:
So I agree that this button is useless in this case.
DanTup commentedon Feb 17, 2025
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:
DanTup commentedon Feb 17, 2025
Tweaked it slightly to have "Show Log":
Hiding the other error popups will be done as part of #5328.
FMorschel commentedon Feb 17, 2025
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!
DanTup commentedon Feb 20, 2025
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.
FMorschel commentedon Feb 20, 2025
It's fine then. If we ever have a meaningful ammount of people who use this feature we can reconsider this.
Thanks a lot!
Show a better error message when running server from source with old SDK