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
Unable to start running/debugging a Flutter app after Flutter daemon crashes, if not restarted #4475
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)
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.
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?
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?
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.
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.
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.
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?
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.
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.
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
@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:
Activity
DanTup commentedon Mar 30, 2023
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_adapterand the shell script could be writing non-JSON (downloading Dart, SDK, building flutter tool etc.) that is breaking the debug adapter protocol.kenzieschmoll commentedon Mar 31, 2023
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:
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?
DanTup commentedon Mar 31, 2023
It could be useful to add these to your Workspace Settings:
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?
polina-c commentedon Apr 3, 2023
I see this regularly. VSCode frame does not turn orange (indicator of debugging). I restart VSCode and then it works normally.
polina-c commentedon Apr 3, 2023
It seems there is error here. 1st and 3rd key is the same. should third be
extensionLogFile?kenzieschmoll commentedon Apr 3, 2023
Yes that is correct.
DanTup commentedon Apr 3, 2023
Oops, yeah :)
DanTup commentedon Apr 4, 2023
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/cachefolder 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.
DanTup commentedon Apr 4, 2023
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.
kenzieschmoll commentedon Apr 4, 2023
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.
DanTup commentedon Apr 4, 2023
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?
DanTup commentedon Apr 5, 2023
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:
Dart-Code/src/extension/providers/debug_config_provider.ts
Lines 165 to 169 in 227be8d
I'll try and improve the handling of this. Some ideas:
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 upgradewith a project open.DanTup commentedon Apr 5, 2023
Oh, in light of this - another log that might be useful:
Handle unresponsive/terminated daemon during launch
DanTup commentedon Apr 5, 2023
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.
kenzieschmoll commentedon Apr 5, 2023
Thanks for the quick fix, Danny. I will collect logs and post here next time the daemon crashes.
kenzieschmoll commentedon Apr 5, 2023
Thanks for the quick fix, Danny. I will collect logs and post here next time the daemon crashes.
DanTup commentedon Apr 5, 2023
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!
[-]Can't run flutter app - infinite progress indicator[/-][+]Unable to start running/debugging a Flutter app after Flutter daemon crashes, if not restarted[/+]polina-c commentedon Apr 5, 2023
Just experienced it and here is the logs:
dap.txt
extensionLogFile.txt
DanTup commentedon Apr 6, 2023
@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:
Thanks!