Closed jeffhollan closed 4 months ago
This is being tracked in the functions host: https://github.com/Azure/azure-functions-host/issues/3543
It's not super clear to me from reading the bugs in azure-functions-host, but I think there is a difference in behavior in vscode somehow.
I'm working on Python functions, and as this bug and the attached external bug says, when I change one of my function files the session ends.
However I can run the same command in a terminal (in this case bash in WSL): (. .venv/bin/activate && func host start
)
When I do that, if I update a function file, the func command auto restarts correctly. So as far as I can tell the function tools are operating correctly (at least for me, with Python) but the extension isn't behaving correctly when the host restarts.
Another thing about the current behavior. It looks like what's happening when a debug session is intered is pip install is run, and then in a new terminal the func command is run. In addition to this method not handling the restart correctly, the new terminal goes away when the func command restarts (and this may be the root of the issue), which means all the output from func goes away as well.
I discovered this because my function was writing files into the function directory (not knowing this would restart the function host) but to me it just looked like my code had made the function host crash. it wasn't until I ran it outside of vscode that I saw that my file changes were causing the restart.
@FISHMANPET there's definitely differences in behavior for VS Code. Here's what we do:
ptvsd_launcher.py
, that's what I'm talking about) If I run func host start
in the terminal, it successfully restarts after a file save as you described. However, if I leverage the setting I just added, I can now see the full logs after a file save while in debug mode and it fails to restart the host with this error:
[10/9/19 6:21:19 PM] Starting worker process failed [10/9/19 6:21:19 PM] The operation has timed out.
This leads me to believe we still need the func cli to fix the above linked issue to get this to work fully.
Could be related: https://github.com/microsoft/vscode/issues/40917
Do we have any idea when this will be worked on? from a developer's perspective this makes having in type of serious flow impossible.
EDIT for those that come across this issue while you can't debug if you run func host start
that will correctly watch and reload. No Debugging but it's better than restarting all the time.
I would also like an ETA please, like @osbornm. For me, workflow with AzFunc is unbearable.
Thank you for all your hard work, devs!
No ETA from VS Code's side. Still blocked on https://github.com/Azure/azure-functions-host/issues/3543
For more details, you can set "azureFunctions.stopFuncTaskPostDebug" to "false", which will prevent the logs from disappearing after you do a file change. You can see that the func cli is running into problems attempting to restart and eventually just stops itself.
[8/12/2020 6:05:13 PM] Starting inspector on 127.0.0.1:9229 failed: address already in use
[8/12/2020 6:05:13 PM] Starting worker process with FileName:node WorkingDirectory:/Users/erijiz/TestRepos/js6 Arguments: --inspect=9229 "/usr/local/Cellar/azure-functions-core-tools@3/3.0.2750/workers/node/dist/src/nodejsWorker.js" --host 127.0.0.1 --port 50183 --workerId ab8becc1-4323-4ff1-a283-c2694318e610 --requestId 9dcd9566-3550-4432-ad51-e2174af3d6b8 --grpcMaxMessageLength 2147483647
[8/12/2020 6:05:13 PM] node process with Id=75852 started
[8/12/2020 6:05:13 PM] Starting inspector on 127.0.0.1:9229 failed: address already in use
[8/12/2020 6:05:13 PM] Starting worker process with FileName:node WorkingDirectory:/Users/erijiz/TestRepos/js6 Arguments: --inspect=9229 "/usr/local/Cellar/azure-functions-core-tools@3/3.0.2750/workers/node/dist/src/nodejsWorker.js" --host 127.0.0.1 --port 50183 --workerId 236c6158-407e-486c-824e-c21f4f920fd4 --requestId ddac141b-4517-4ca1-b66e-682ae0d7513c --grpcMaxMessageLength 2147483647
[8/12/2020 6:05:13 PM] node process with Id=75853 started
[8/12/2020 6:05:13 PM] Starting inspector on 127.0.0.1:9229 failed: address already in use
[8/12/2020 6:05:13 PM] Exceeded language worker restart retry count for runtime:node. Shutting down and proactively recycling the Functions Host to recover
[8/12/2020 6:05:13 PM] Stopping host...
[8/12/2020 6:05:13 PM] Stopping JobHost
[8/12/2020 6:05:13 PM] Job host stopped
[8/12/2020 6:05:13 PM] Host restarted.
[8/12/2020 6:05:13 PM] Stopping JobHost
[8/12/2020 6:05:13 PM] Job host stopped
[8/12/2020 6:05:13 PM] Host shutdown completed.
With that in mind, not much we can do other than bother the Functions team. Per this comment seems like they're aware of the problem and have looked into it, but it's not an easy thing to fix.
For anyone still trying to get this work on Mac, I got it to work using the "restart" property in the task and with the following arguments:
func start --javascript --language-worker -- "--inspect=9229"
Launch.json
{
"name": "Debug Azure Functions API",
"type": "node",
"request": "attach",
"port": 9229,
"restart": true
}
Hey, bumping this as I'd love to see this getting solved
Is there any update on this?
Hey, this issue is better covered at https://github.com/Azure/azure-functions-core-tools/issues/1239. With this solution being the current prime workaround. My team has been using it for a while now and it's a huge time-saver and seems stable 90% of the time.
Feature Request:
The azure functions host will automatically detect file changes and reload. This is nice for javascript where you can make a quick edit in code and have host pick it up right away. However in VS Code the debug session terminates somewhere in this process. Not a huge deal but would be nice if the file watch and host restart could maintain a debug session. May include an ask on restart behavior for azure/azure-functions-core-tools
Extension version: 0.12.0 VS Code version: Code - Insiders 1.29.0-insider (d43f6cb9947c57a3254b556e69aeacc2b2025184, 2018-11-02T15:50:03.156Z) OS version: Darwin x64 18.2.0