Skip to content

Unable to start running/debugging a Flutter app after Flutter daemon crashes, if not restarted #4475

Closed

Description

@kenzieschmoll

vs-code-not-running

This happens to me almost daily. At some point, clicking run to run my flutter app just hangs. I always have to run Developer: Reload window to fix the issue. I opened the developer logs and saw this.

  ERR File is not being analyzed: Error: File is not being analyzed
	at handleResponse (/Users/kenzieschmoll/.vscode/extensions/dart-code.dart-code-3.61.20230324/out/dist/extension.js:29849:48)
	at processMessageQueue (/Users/kenzieschmoll/.vscode/extensions/dart-code.dart-code-3.61.20230324/out/dist/extension.js:29645:17)
	at Immediate.<anonymous> (/Users/kenzieschmoll/.vscode/extensions/dart-code.dart-code-3.61.20230324/out/dist/extension.js:29629:13)
	at process.processImmediate (node:internal/timers:466:21)

Screenshot 2023-03-30 at 11 35 07 AM

Activity

  1. DanTup commented on Mar 30, 2023

    @DanTup
    Member

    Yikes. I don't think any of the errors listed are related.

    Can you confirm the version of Flutter you're currently using, which folder from DevTools you have open, and whether you're on the pre-release Dart extension or the stable one?

    Is it possible this happens after you pull a new Flutter version? I wonder whether we're spawning flutter debug_adapter and the shell script could be writing non-JSON (downloading Dart, SDK, building flutter tool etc.) that is breaking the debug adapter protocol.

  2. added
    awaiting infoRequires more information from the customer to progress
    on Mar 30, 2023
  3. kenzieschmoll commented on Mar 31, 2023

    @kenzieschmoll
    Author

    This has been happening for a while, so I don't think this is a recent regression or change with Flutter, but I was on:

    Flutter 3.9.0-20.0.pre.13 • channel master •
    [email protected]:flutter/flutter.git
    Framework • revision 4e1ad59f75 (2 days ago) • 2023-03-30 01:06:46
    +0200
    Engine • revision 45467e2a8b
    Tools • Dart 3.0.0 (build 3.0.0-378.0.dev) • DevTools 2.22.2
    

    I have the devtools/packages/ folder opened.

    Dart code extension: v3.61.20230330 (pre-release).

    This doesn't happen only when I pull a new flutter version. It happens more frequently than that. I will try to pay attention to what my previous steps were next time I see it. Any logs I can collect for the next time this occurs?

  4. DanTup commented on Mar 31, 2023

    @DanTup
    Member

    It could be useful to add these to your Workspace Settings:

    "dart.dapLogFile": "logs/dap.txt",
    "dart.vmServiceLogFile": "logs/vmService.txt",
    "dart.extensionLogFile": "logs/extensionLogFile.txt",
    

    I'm not sure which will be useful because I'm not sure where it's stalling. You'd probably also want to gitignore the logs folder. Then next time you see it, you could grab a copy of them and there might be some clues.

    Do you know if anyone else on the team is seeing the same?

  5. polina-c commented on Apr 3, 2023

    @polina-c

    I see this regularly. VSCode frame does not turn orange (indicator of debugging). I restart VSCode and then it works normally.

  6. polina-c commented on Apr 3, 2023

    @polina-c
    "dart.dapLogFile": "logs/dap.txt"
    "dart.vmServiceLogFile": "logs/vmService.txt"
    "dart.dapLogFile": "logs/extensionLogFile.txt"
    

    It seems there is error here. 1st and 3rd key is the same. should third be extensionLogFile?

  7. kenzieschmoll commented on Apr 3, 2023

    @kenzieschmoll
    Author

    It seems there is error here. 1st and 3rd key is the same. should third be extensionLogFile?

    Yes that is correct.

  8. DanTup commented on Apr 3, 2023

    @DanTup
    Member

    should third be extensionLogFile?

    Oops, yeah :)

  9. DanTup commented on Apr 4, 2023

    @DanTup
    Member

    Next time someone sees this, is it possible you can also leave it for a little while (at least a few minutes) to see whether it eventually starts?

    I deleted my Flutter bin/cache folder to see what the behaviour is if Flutter does trigger some download in the shell script before starting the debug adapter, and it looks similar to what's described here, but after some time (when the download has finished), the session starts normally (I guess it's not writing anything to stdout that's interfering with the startup).

    If the same is true for you, then it might that Flutter is doing something before the debug adapter is ready. If not, then hopefully the logs will help understand what's happening.

  10. DanTup commented on Apr 4, 2023

    @DanTup
    Member

    I guess it's not writing anything to stdout that's interfering with the startup

    Actually, it is. But it looks like we got lucky here and the way VS Code's DAP parses the headers is essentially ignoring output before the real DAP output (I added some notes to flutter/flutter#94406 (comment)).

    Unfortunately the way we log DAP output means we might not capture this in any of the logs noted above, so it might be hard to confirm this is exactly what's happening (although if we suspect this, we might be able to do something).

    I think the first thing to figure out is whether it eventually starts, or if it's just completely broken.

    Another thing to check that I forgot to mention is Help -> Toggle Developer Tools in VS Code, then click on the Console tab and see if there are any errors listed there.

  11. kenzieschmoll commented on Apr 4, 2023

    @kenzieschmoll
    Author

    Some more info that might help. I got a prompt that the flutter daemon terminated. I wanted to see if this could be related to the issue we are seeing here, so I closed the prompt, then clicked run and I reproduced the issue. So maybe run / debug should try to restart the flutter daemon if it is terminated at the time of clicking run?
    dap.txt

    I also waited a while like you suggested, and nothing happened.

  12. DanTup commented on Apr 4, 2023

    @DanTup
    Member

    I got a prompt that the flutter daemon terminated. I wanted to see if this could be related to the issue we are seeing here, so I closed the prompt, then clicked run and I reproduced the issue.

    Ah, that could explain it. When launching, we do interact with the daemon to ensure the selected device is valid. I'll see if I can repro by forcing it to terminate and see what the best way to handle is.

    Next time you see this, I think there should be a "Show Log" button on the "Daemon has terminated" prompt - could you check if there are any clues in there about why it terminated?

  13. DanTup commented on Apr 5, 2023

    @DanTup
    Member

    I can reproduce it by terminating the Flutter daemon. We're getting stuck here trying to ask it for the supported platforms for the project:

    if (requiresDevice) {
    if (this.deviceManager && this.daemon && debugConfig.deviceId !== "flutter-tester") {
    let supportedPlatforms = this.daemon.capabilities.providesPlatformTypes && debugConfig.cwd
    ? (await this.daemon.getSupportedPlatforms(debugConfig.cwd)).platforms
    : undefined;

    I'll try and improve the handling of this. Some ideas:

    • skip the check and just assume if the daemon doesn't respond quickly
    • re-show the "Flutter daemon has terminated" prompt (in case it's been collapsed by VS Code) and then continue once user clicks restart
    • automatically restart the daemon with some progress notification instead of waiting for the user to click the button (and give up after 5 restarts or something)

    We should definitely figure out why why the daemon is crashing for you frequently though. I tend to only see this when doing something like a flutter upgrade with a project open.

  14. DanTup commented on Apr 5, 2023

    @DanTup
    Member

    Oh, in light of this - another log that might be useful:

    "dart.flutterDaemonLogFile": "logs/flutter_daemon.txt"
    
  15. added
    in flutterRelates to running Flutter apps
    in debuggingRelates to the debug adapter or process of running debug sessions
    and removed
    awaiting infoRequires more information from the customer to progress
    on Apr 5, 2023
  16. added this to the v3.64.0 milestone on Apr 5, 2023
  17. DanTup commented on Apr 5, 2023

    @DanTup
    Member

    I've pushed a fix that will skip checking if the device is valid if the daemon has terminated, or if it doesn't respond within 5s.

    It's available in the v3.63.20230405 pre-release version of the Dart extension I just pushed.

    I've also opened #4485 to look at a better way we can restart services like the Daemon. Right now a "restart" of things like this are actually just full extension reloads (which means the analysis server, and everything else) because the base implementation of these services doesn't support cleanly restarting (since there may be open requests from different parts of the extension).

    I'm still interested to learn why your daemons are crashing so frequently though. I'd like to see a log file when this happens if there's anything in there about why it might have terminated. The extension assumes the daemon is always available and if it's not reliable, we need to track down why.

  18. kenzieschmoll commented on Apr 5, 2023

    @kenzieschmoll
    Author

    Thanks for the quick fix, Danny. I will collect logs and post here next time the daemon crashes.

  19. kenzieschmoll commented on Apr 5, 2023

    @kenzieschmoll
    Author

    Thanks for the quick fix, Danny. I will collect logs and post here next time the daemon crashes.

  20. DanTup commented on Apr 5, 2023

    @DanTup
    Member

    Great, thanks! A new issue would be better since that might have a different fix (and I use issues for items in release notes). Thanks!

  21. changed the title [-]Can't run flutter app - infinite progress indicator[/-] [+]Unable to start running/debugging a Flutter app after Flutter daemon crashes, if not restarted[/+] on Apr 5, 2023
  22. polina-c commented on Apr 5, 2023

    @polina-c

    Just experienced it and here is the logs:

    dap.txt
    extensionLogFile.txt

  23. DanTup commented on Apr 6, 2023

    @DanTup
    Member

    @polina-c are you on the pre-release version of the extension? Do you know if it was installed (and reloaded) when you hit this? I was expecting the issue to be resolved if you're using the pre-release (although, since you included a DAP log showing a debug session, I'm also not sure exactly what you saw).

    If you think you're still seeing this with the pre-release version of the extension published yesterday (v3.63.20230405) and it's definitely been reloaded since it finished installing, please let me know.

    Otherwise, it's mostly the daemon log I'm interested in now, to understand why your daemons are crashing:

    "dart.flutterDaemonLogFile": "logs/flutter_daemon.txt"
    

    Thanks!

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

    in debuggingRelates to the debug adapter or process of running debug sessionsin flutterRelates to running Flutter appsis bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions