flask + docker + remote debugging: Debug adapter process has terminated unexpectedly
See original GitHub issueEnvironment 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:
- Start docker containers on local machine
- webapp is waiting for remote debugger to connect
- VS Code debugger does not attach
Logs
Output for Python
in the Output
panel (View
→Output
, 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
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Debug adapter process has terminated unexpectedly #71
One thing that doesn't seem to work on the remote-debugging-docker-django is breakpoints. They all show up as 'unverified breakpoint'. We're currently working ...
Read more >Debug adapter process has terminated unexpectedly
As I finish debugging a script, I consistently get an error - "Debug adapter process has terminated unexpectedly".
Read more >Remote debugging with VSCode, Docker and Pico - Hipo
Time to debug! Not so fast… Debug adapter process has terminated unexpectedly. I tried multiple times but kept getting this nasty error:.
Read more >Dockerize a Flask app and debug with VSCode
So in this tutorial, I want to share a way to set up a development environment with Flask, Docker and VSCode. You can...
Read more >Flask Debugging in VS Code with Hot-Reload - Theodo blog
Here we have setup a simple flask-server service that will run our Flask application inside a Docker container. Step 2: Setup the debugger....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After removing the
secret
ptvsd works as expected with 2018.8.0, thank you@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 theenable_attach
method.Once done, please get back to us.