microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.31k stars 1.18k forks source link

Latest python extension for VSCode is failing on azure function debugging #8685

Closed svangeti closed 4 years ago

svangeti commented 4 years ago
[11/20/19 4:52:56 PM] Starting worker process:python  /Users/user/.vscode/extensions/ms-python.python-2019.11.49689/pythonFiles/lib/python/new_ptvsd/no_wheels/ptvsd --default --host 127.0.0.1 --port 9091 --wait "/usr/local/Cellar/azure-functions-core-tools/2.7.1846/workers/python/3.7/OSX/X64/worker.py" --host 127.0.0.1 --port 50537 --workerId 07b64633-c116-433b-bb4c-b5209f85cec1 --requestId f0f35b48-8733-476c-bb66-4eeb0ef34b33 --grpcMaxMessageLength 134217728
[11/20/19 4:52:56 PM] python process with Id=15422 started
[11/20/19 4:52:56 PM] ptvsd 5.0.0a7
[11/20/19 4:52:56 PM] See https://aka.ms/ptvsd for documentation.
[11/20/19 4:52:56 PM] Usage: ptvsd [--client] --host <address> [--port <port>]
[11/20/19 4:52:56 PM]              [--wait]
[11/20/19 4:52:56 PM]              [--no-subprocesses]
[11/20/19 4:52:56 PM]              [--log-dir <path>] [--log-stderr]
[11/20/19 4:52:56 PM]              <filename> | -m <module> | -c <code> | --pid <pid>
[11/20/19 4:52:56 PM] Error: unrecognized switch --default

Environment data

launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Attach to Python Functions",
      "type": "python",
      "request": "attach",
      "port": 9091,
      "preLaunchTask": "func: host start"
    }
  ]
}

Expected behaviour

Should be able to debug azure functions from VS Code local

Actual behaviour

Failing the debug with above error.

Steps to reproduce:

  1. Create Azure function with Azure function extension

Logs

python process with Id=15426 started
[11/20/19 4:52:56 PM] ptvsd 5.0.0a7
[11/20/19 4:52:56 PM] See https://aka.ms/ptvsd for documentation.
[11/20/19 4:52:56 PM] Usage: ptvsd [--client] --host <address> [--port <port>]
[11/20/19 4:52:56 PM]              [--wait]
[11/20/19 4:52:56 PM]              [--no-subprocesses]
[11/20/19 4:52:56 PM]              [--log-dir <path>] [--log-stderr]
[11/20/19 4:52:56 PM]              <filename> | -m <module> | -c <code> | --pid <pid>
[11/20/19 4:52:56 PM] Error: unrecognized switch --default
[11/20/19 4:52:56 PM] Exceeded language worker restart retry count for runtime:python. Shutting down Functions Host
[11/20/19 4:52:56 PM] Stopping host...
[11/20/19 4:52:56 PM] Stopping JobHost
[11/20/19 4:52:56 PM] Job host stopped
[11/20/19 4:52:56 PM] Host shutdown completed.
karthiknadig commented 4 years ago

@svangeti Thanks for reporting this issue. Created a PR addressing this #8712

karthiknadig commented 4 years ago

@svangeti we have released version 2019.11.50794 of the extension with a fix. Please try it and let us know.

EParisot commented 4 years ago

Hi, I still have the same problem on a fresh (today) install...

[23/11/2019 11:51:29] Error: unrecognized switch --default

Anyway, I downgraded to 2019.10.44104 and it works perfectly

Thanks

karthiknadig commented 4 years ago

@EParisot Can you provide the output for python? At the top you should see something like this. Can you share that? image.png

EParisot commented 4 years ago

@karthiknadig I have nothing il the "Output" pannel ... the error appears in the "Terminal":

> Executing task: . .venv/Scripts/activate && func host start

Found Python version 3.7.3 (python).

                  %%%%%%
                 %%%%%%
            @   %%%%%%    @
          @@   %%%%%%      @@
       @@@    %%%%%%%%%%%    @@@
     @@      %%%%%%%%%%        @@
       @@         %%%%       @@
         @@      %%%       @@
           @@    %%      @@
                %%
                %

Azure Functions Core Tools (2.7.1846 Commit hash: 458c671341fda1c52bd46e1aa8943cb26e467830)
Function Runtime Version: 2.0.12858.0
[27/11/2019 09:50:10] File 'C:\Program Files (x86)\dotnet\dotnet.exe' is not found, 'dotnet' invocation will rely on the PATH environment variable.
[27/11/2019 09:50:10] Building host: startup suppressed: 'False', configuration suppressed: 'False', startup operation id: 'dea9856f-469d-46cc-825e-f98376190407'    
[27/11/2019 09:50:10] Reading functions metadata
[27/11/2019 09:50:10] 1 functions found
[27/11/2019 09:50:11] File 'C:\Program Files (x86)\dotnet\dotnet.exe' is not found, 'dotnet' invocation will rely on the PATH environment variable.
[27/11/2019 09:50:11] Initializing Warmup Extension.
[27/11/2019 09:50:11] Initializing Host. OperationId: 'dea9856f-469d-46cc-825e-f98376190407'.
[27/11/2019 09:50:11] Host initialization: ConsecutiveErrors=0, StartupCount=1, OperationId=dea9856f-469d-46cc-825e-f98376190407
[27/11/2019 09:50:11] LoggerFilterOptions
[27/11/2019 09:50:11] {
[27/11/2019 09:50:11]   "MinLevel": "None",
[27/11/2019 09:50:11]   "Rules": [
[27/11/2019 09:50:11]     {
[27/11/2019 09:50:11]       "ProviderName": null,
[27/11/2019 09:50:11]       "CategoryName": null,
[27/11/2019 09:50:11]       "LogLevel": null,
[27/11/2019 09:50:11]       "Filter": "<AddFilter>b__0"
[27/11/2019 09:50:11]     },
[27/11/2019 09:50:11]     {
[27/11/2019 09:50:11]       "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[27/11/2019 09:50:11]       "CategoryName": null,
[27/11/2019 09:50:11]       "LogLevel": "None",
[27/11/2019 09:50:11]       "Filter": null
[27/11/2019 09:50:11]     },
[27/11/2019 09:50:11]     {
[27/11/2019 09:50:11]       "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[27/11/2019 09:50:11]       "CategoryName": null,
[27/11/2019 09:50:11]       "LogLevel": null,
[27/11/2019 09:50:11]       "Filter": "<AddFilter>b__0"
[27/11/2019 09:50:11]     }
[27/11/2019 09:50:11]   ]
[27/11/2019 09:50:11] }
[27/11/2019 09:50:11] FunctionResultAggregatorOptions
[27/11/2019 09:50:11] {
[27/11/2019 09:50:11]   "BatchSize": 1000,
[27/11/2019 09:50:11]   "FlushTimeout": "00:00:30",
[27/11/2019 09:50:11]   "IsEnabled": true
[27/11/2019 09:50:11] }
[27/11/2019 09:50:11] SingletonOptions
[27/11/2019 09:50:11] {
[27/11/2019 09:50:11]   "LockPeriod": "00:00:15",
[27/11/2019 09:50:11]   "ListenerLockPeriod": "00:00:15",
[27/11/2019 09:50:11]   "LockAcquisitionTimeout": "10675199.02:48:05.4775807",
[27/11/2019 09:50:11]   "LockAcquisitionPollingInterval": "00:00:05",
[27/11/2019 09:50:11]   "ListenerLockRecoveryPollingInterval": "00:01:00"
[27/11/2019 09:50:11] }
[27/11/2019 09:50:11] HttpOptions
[27/11/2019 09:50:11] {
[27/11/2019 09:50:11]   "DynamicThrottlesEnabled": false,
[27/11/2019 09:50:11]   "MaxConcurrentRequests": -1,
[27/11/2019 09:50:11]   "MaxOutstandingRequests": -1,
[27/11/2019 09:50:11]   "RoutePrefix": "api"
[27/11/2019 09:50:11] }
[27/11/2019 09:50:11] Starting JobHost
[27/11/2019 09:50:11] Starting Host (HostId=notebookeric-394490986, InstanceId=33328604-8496-465b-901b-2d9e3a20f98e, Version=2.0.12858.0, ProcessId=29948, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=(null))
[27/11/2019 09:50:11] Loading functions metadata
[27/11/2019 09:50:11] 1 functions loaded
[27/11/2019 09:50:11] Loading proxies metadata
[27/11/2019 09:50:11] Initializing Azure Function proxies
[27/11/2019 09:50:12] 0 proxies loaded
[27/11/2019 09:50:12] Starting worker process:python  c:\Users\Rock_\.vscode\extensions\ms-python.python-2019.11.50794\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd --default --host 127.0.0.1 --port 9091 --wait "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\3.7/WINDOWS/X64/worker.py" --host 127.0.0.1 --port 30954 --workerId 91704057-4e00-410c-8c98-f5390b1e9033 --requestId 4997a52d-3e14-4c39-808c-285ffe727db6 --grpcMaxMessageLength 134217728
[27/11/2019 09:50:12] python process with Id=26984 started
[27/11/2019 09:50:12] Generating 1 job function(s)
[27/11/2019 09:50:12] Found the following functions:
[27/11/2019 09:50:12] Host.Functions.test
[27/11/2019 09:50:12]
[27/11/2019 09:50:12] Initializing function HTTP routes
[27/11/2019 09:50:12] Mapped function route 'api/test' [get,post] to 'test'
[27/11/2019 09:50:12]
[27/11/2019 09:50:12] Host initialized (680ms)
[27/11/2019 09:50:12] Host started (706ms)
[27/11/2019 09:50:12] Job host started
Hosting environment: Production
Content root path: c:\Users\Rock_\Desktop\test
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.

Http Functions:

        test: [GET,POST] http://localhost:7071/api/test

[27/11/2019 09:50:12] ptvsd 5.0.0a7
[27/11/2019 09:50:12] See https://aka.ms/ptvsd for documentation.
[27/11/2019 09:50:12] Usage: ptvsd [--client] --host <address> [--port <port>]
[27/11/2019 09:50:12]              [--wait]
[27/11/2019 09:50:12]              [--no-subprocesses]
[27/11/2019 09:50:12]              [--log-dir <path>] [--log-stderr]
[27/11/2019 09:50:12]              <filename> | -m <module> | -c <code> | --pid <pid>
[27/11/2019 09:50:12] Error: unrecognized switch --default
[27/11/2019 09:50:12] Starting worker process:python  c:\Users\Rock_\.vscode\extensions\ms-python.python-2019.11.50794\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd --default --host 127.0.0.1 --port 9091 --wait "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\3.7/WINDOWS/X64/worker.py" --host 127.0.0.1 --port 30954 --workerId f5492fe8-33b3-4340-b097-77b93053a4cc --requestId 7a4b6ed9-aa76-4518-a30a-eda8debec651 --grpcMaxMessageLength 134217728
[27/11/2019 09:50:12] python process with Id=23976 started
[27/11/2019 09:50:13] ptvsd 5.0.0a7
[27/11/2019 09:50:13] See https://aka.ms/ptvsd for documentation.
[27/11/2019 09:50:13] Usage: ptvsd [--client] --host <address> [--port <port>]
[27/11/2019 09:50:13]              [--wait]
[27/11/2019 09:50:13]              [--no-subprocesses]
[27/11/2019 09:50:13]              [--log-dir <path>] [--log-stderr]
[27/11/2019 09:50:13] Starting worker process:python  c:\Users\Rock_\.vscode\extensions\ms-python.python-2019.11.50794\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd --default --host 127.0.0.1 --port 9091 --wait "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\3.7/WINDOWS/X64/worker.py" --host 127.0.0.1 --port 30954 --workerId f9bb710c-359f-4e24-8b61-af1986b2ecf4 --requestId f6ade7dd-4e1d-4d7e-8071-63e7fb5b9257 --grpcMaxMessageLength 134217728
[27/11/2019 09:50:13]              <filename> | -m <module> | -c <code> | --pid <pid>
[27/11/2019 09:50:13] Error: unrecognized switch --default
[27/11/2019 09:50:13] python process with Id=22596 started
[27/11/2019 09:50:14] ptvsd 5.0.0a7
[27/11/2019 09:50:14] See https://aka.ms/ptvsd for documentation.
[27/11/2019 09:50:14] Usage: ptvsd [--client] --host <address> [--port <port>]
[27/11/2019 09:50:14]              [--wait]
[27/11/2019 09:50:14]              [--no-subprocesses]
[27/11/2019 09:50:14]              [--log-dir <path>] [--log-stderr]
[27/11/2019 09:50:14]              <filename> | -m <module> | -c <code> | --pid <pid>
[27/11/2019 09:50:14] Error: unrecognized switch --default
[27/11/2019 09:50:14] Exceeded language worker restart retry count for runtime:python. Shutting down Functions Host
[27/11/2019 09:50:14] Stopping host...
[27/11/2019 09:50:14] Stopping JobHost
[27/11/2019 09:50:14] Job host stopped
[27/11/2019 09:50:14] Host shutdown completed.
Application is shutting down...
karthiknadig commented 4 years ago

@EParisot I am particularly looking for the experiment groups that the extension is in. you will get that only in the Output panel. you can get to it like this: ViewOutput, change the drop-down the upper-right of the Output panel to Python.

You should find these lines at the top. Please share all the User belongs to lines.

User belongs to experiment group 'ShowPlayIcon - start'
User belongs to experiment group 'ShowExtensionSurveyPrompt - control'
User belongs to experiment group 'DebugAdapterFactory - control'
User belongs to experiment group 'LS - control'

The issue is that there is a mismatch in experiment conditions where we check for the debugger version and the corresponding launch arguments.

EParisot commented 4 years ago

Alright, it wasn't obvious to me sry :

User belongs to experiment group 'ShowPlayIcon - start'
User belongs to experiment group 'DebugAdapterFactory - experiment'
User belongs to experiment group 'AA_testing - experiment'
Armcollector commented 4 years ago

I also have the same problem. I am on: 2019.11.50794

kimadeline commented 4 years ago

✅ Validated, debugging of locally deployed Azure Functions works in 2019.12.51221-dev when in the following experiments:

User belongs to experiment group 'ShowPlayIcon - start'
User belongs to experiment group 'DebugAdapterFactory - experiment'
User belongs to experiment group 'PtvsdWheels37 - control'

@svangeti , @EParisot and @Armcollector the fix is available in our latest Insiders build, otherwise it will be deployed in the next release of the Python extension.