Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flask + docker + remote debugging: Debug adapter process has terminated unexpectedly #2602

Closed
Brice187 opened this issue Sep 17, 2018 · 5 comments
Labels
area-debugging bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@Brice187
Copy link

Environment data

  • VS Code version: 1.27.2
  • Extension version (available under the Extensions sidebar): 2018.8.0
  • OS and version: Debian 9.5 - Kernel 4.9.0-8-amd64
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.5
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): none
  • Relevant/affected Python packages and their versions: Flask 0.12.2, ptvsd 3.0.0
  • App running in actual Docker

Actual behavior

Remote Debugger does not attach to the flask app running in a docker container on localhost

Expected behavior

Remote Debugger attaches to the flask app running in a docker container on localhost.
Worked on VS Code < 1.27

Steps to reproduce:

  1. Start docker containers on local machine
  2. webapp is waiting for remote debugger to connect
  3. VS Code debugger does not attach

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

No Output
notificationsAlerts.ts:41 Debug adapter process has terminated unexpectedly
t.onDidNotificationChange @ notificationsAlerts.ts:41
(anonymous) @ notificationsAlerts.ts:27
e.fire @ event.ts:140
t.notify @ notifications.ts:113
t.error @ notificationService.ts:52
t.onDebugAdapterExit @ rawDebugSession.ts:529
(anonymous) @ rawDebugSession.ts:169
e.fire @ event.ts:140
(anonymous) @ debugAdapter.ts:305
emitTwo @ events.js:126
emit @ events.js:214
__dirname.ChildProcess._handle.onexit @ internal/child_process.js:198

----------------------------------------------------------

[Extension Host] Python Extension: Error in debugger Banner Error: Missing required @injectable annotation in: Random.
	at getTargets (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/node_modules/inversify/lib/planning/reflection_utils.js:20:15)
	at Object.getDependencies (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/node_modules/inversify/lib/planning/reflection_utils.js:11:19)
	at /home/lars/.vscode/extensions/ms-python.python-2018.8.0/node_modules/inversify/lib/planning/planner.js:106:51
	at Array.forEach (<anonymous>)
	at _createSubRequests (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/node_modules/inversify/lib/planning/planner.js:94:20)
	at Object.plan (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/node_modules/inversify/lib/planning/planner.js:129:9)
	at /home/lars/.vscode/extensions/ms-python.python-2018.8.0/node_modules/inversify/lib/container/container.js:316:37
	at Container._get (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/node_modules/inversify/lib/container/container.js:309:44)
	at Container.get (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/node_modules/inversify/lib/container/container.js:228:21)
	at ServiceContainer.get (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/out/client/ioc/container.js:28:89)
	at DebuggerBanner.<anonymous> (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/out/client/debugger/banner.js:163:55)
	at Generator.next (<anonymous>)
	at /home/lars/.vscode/extensions/ms-python.python-2018.8.0/out/client/debugger/banner.js:18:71
	at new Promise (<anonymous>)
	at __awaiter (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/out/client/debugger/banner.js:14:12)
	at DebuggerBanner.getDebuggerLaunchThresholdCounter (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/out/client/debugger/banner.js:158:16)
	at DebuggerBanner.<anonymous> (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/out/client/debugger/banner.js:135:22)
	at Generator.next (<anonymous>)
	at /home/lars/.vscode/extensions/ms-python.python-2018.8.0/out/client/debugger/banner.js:18:71
	at new Promise (<anonymous>)
	at __awaiter (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/out/client/debugger/banner.js:14:12)
	at DebuggerBanner.passedThreshold (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/out/client/debugger/banner.js:133:16)
	at DebuggerBanner.<anonymous> (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/out/client/debugger/banner.js:72:30)
	at Generator.next (<anonymous>)
	at /home/lars/.vscode/extensions/ms-python.python-2018.8.0/out/client/debugger/banner.js:18:71
	at new Promise (<anonymous>)
	at __awaiter (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/out/client/debugger/banner.js:14:12)
	at DebuggerBanner.shouldShow (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/out/client/debugger/banner.js:68:16)
	at DebuggerBanner.<anonymous> (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/out/client/debugger/banner.js:188:37)
	at Generator.next (<anonymous>)
	at fulfilled (/home/lars/.vscode/extensions/ms-python.python-2018.8.0/out/client/debugger/banner.js:15:58)
	at <anonymous>

debug.log

10:19:47 AM, 9/17/2018
Started @ Mon Sep 17 2018 10:19:47 GMT+0200 (CEST)
From Client:
Content-Length: 313

{"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"python","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us"},"type":"request","seq":1}
To Client:
Content-Length: 653

{"seq":1,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"supportsExceptionInfoRequest":true,"supportsConfigurationDoneRequest":true,"supportsConditionalBreakpoints":true,"supportsSetVariable":true,"supportsExceptionOptions":true,"supportsEvaluateForHovers":true,"supportsModulesRequest":true,"supportsValueFormattingOptions":true,"supportsHitConditionalBreakpoints":true,"supportsSetExpression":true,"supportsLogPoints":true,"supportTerminateDebuggee":true,"exceptionBreakpointFilters":[{"filter":"raised","label":"Raised Exceptions","default":false},{"filter":"uncaught","label":"Uncaught Exceptions","default":true}]}}
From Client:
Content-Length: 385

{"command":"attach","arguments":{"name":"Attach (to Docker)","logToFile":true,"type":"python","request":"attach","pathMappings":[{"localRoot":"/home/lars/dev/MWScan-Portal/web/flask/","remoteRoot":"/home/flask/app/web/flask/"}],"port":3000,"host":"127.0.0.1","debugOptions":["RedirectOutput","UnixClient"],"__sessionId":"1d2e5bbc-f18a-4460-b9f9-1e934f2ac312"},"type":"request","seq":2}
To Client:
Content-Length: 385


To Client:
{"command":"attach","arguments":{"name":"Attach (to Docker)","logToFile":true,"type":"python","request":"attach","pathMappings":[{"localRoot":"/home/lars/dev/MWScan-Portal/web/flask/","remoteRoot":"/home/flask/app/web/flask/"}],"port":3000,"host":"127.0.0.1","debugOptions":["RedirectOutput","UnixClient"],"__sessionId":"1d2e5bbc-f18a-4460-b9f9-1e934f2ac312"},"type":"request","seq":2}
To Client:
Content-Length: 313


To Client:
{"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"python","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us"},"type":"request","seq":1}
To Client:
PTVSDBG�
Socket End
check and shutdown
shutdown
Sending Terminated Event
To Client:
Content-Length: 45


To Client:
{"seq":0,"type":"event","event":"terminated"}
Shutting down debug session
disposing

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach (to Docker)",
            "logToFile": true,
            "type": "python",
            "request": "attach",
            "pathMappings": [
                {
                    "localRoot": "${workspaceRoot}/web/flask/",
                    "remoteRoot": "/home/flask/app/web/flask/",
                }
            ],
            "port": 3000,
            "host": "localhost",
        },
    ]

docker-compose.yml

version: '2'

services:
 web:
   build:
     context: ./web
   depends_on:
     - postgres
   ports:
     - "5000:5000"
     - "3000:3000"
   environment:
     - FLASK_APP=flask/app.py
   volumes:
     - ./web/:/home/flask/app/web/
     - ./samples/:/samples
   command: flask run --host=0.0.0.0 --no-debugger --no-reload

app.py

import ptvsd

try:
    ptvsd.enable_attach(address=('0.0.0.0', 3000), secret=None)
    ptvsd.wait_for_attach()
except Exception as ex:
    print('Not working: ')

telnet 127.0.0.1 3000 (on developer machine)

lars@laptop:/$ telnet 127.0.0.1 3000
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
PTVSDBG�
@Brice187
Copy link
Author

Okay, i foudn out that the bug was introduced in the python extension 2018.8.0.

Just downgraded to 2018.7.0 and everything is working as expected.

@d3r3kk d3r3kk added bug Issue identified by VS Code Team member as probable bug needs PR area-debugging info-needed Issue requires more information from poster and removed needs PR labels Sep 17, 2018
@d3r3kk
Copy link

d3r3kk commented Sep 17, 2018

Thanks for the report @Brice187,

If you have the time, could you please try to install the latest development build of our extension and see if that fixes the issue for you? Let us know if that takes care of the issue.

(I suspect this is related to #2557)

@Brice187
Copy link
Author

@d3r3kk This bug is still present in 2018.9.0-alpha

Back to 2018.7.0...

@brettcannon brettcannon added needs verification and removed info-needed Issue requires more information from poster labels Sep 18, 2018
@DonJayamanne
Copy link

DonJayamanne commented Oct 1, 2018

@Brice187
Please ensure you are using the latest version of PTVSD in the docker container.
It looks like you don't have it at your end, the new version doesn't require the secret in the enable_attach method.

Once done, please get back to us.

@DonJayamanne DonJayamanne added info-needed Issue requires more information from poster and removed needs verification labels Oct 1, 2018
@Brice187
Copy link
Author

Brice187 commented Oct 7, 2018

After removing the secret ptvsd works as expected with 2018.8.0, thank you

@lock lock bot locked as resolved and limited conversation to collaborators Nov 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-debugging bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

4 participants