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

debug: dlv-dap mode doesn't handle launch failure when current opened file is launch.json #1413

Closed
polinasok opened this issue Apr 9, 2021 · 2 comments
Assignees
Labels
Debug Issues related to the debugging functionality of the extension. FrozenDueToAge
Milestone

Comments

@polinasok
Copy link
Contributor

            "name": "Launch file",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${file}",
            //"debugAdapter": "dlv-dap",
            "showLog": true,
            "logOutput": "rpc,debugger,dap",

The following often happens to me:

  • Have .go file and a launch.json file open
  • Select launch.json to check some option and/or make some change
  • Forget to navigate back to the go file
  • Start debugging
  • Get a pop-up Failed to continue: "The program attribute must be a directory or .go file in debug mode" with the following logged in the Debug Console: The program "/Users/polina/go/src/foo/.vscode/launch.json" must be a valid go file in debug mode

Doing the same with "debugAdapter": "dlv-dap", I get only this in the log (no launch failure logging)

Running: /Users/polina/go/bin/dlv-dap dap --listen=127.0.0.1:63983 --log=true --log-output=rpc,debugger,dap

and then nothing but the option to stop/restart with the little blue marker running and running in the UI:
image
I then have to manually click Stop.

If I do the same thing using "debugServer":54321 to connect to an external instance of dlv-dap running in another terminal at port 54321, I get a (less informative) pop-up

Failed to launch: Build error: exit status 1

and the following log

2021-04-08T17:53:10-07:00 debug layer=dap building binary at /Users/polina/delve/__debug_bin
can't load package: package /Users/polina/go/src/foo/.vscode/launch.json: cannot find package
@polinasok polinasok added Debug Issues related to the debugging functionality of the extension. DlvDAP labels Apr 9, 2021
@hyangah
Copy link
Contributor

hyangah commented Apr 9, 2021

Thanks for the report. I see the following log from the dev console.

  ERR The program attribute must be a directory or .go file in debug and test mode: Error: The program attribute must be a directory or .go file in debug and test mode
    at parseProgramArgSync (/Users/hakim/.vscode/extensions/golang.go-0.24.0/dist/goMain.js:59719:15)
    at /Users/hakim/.vscode/extensions/golang.go-0.24.0/dist/goMain.js:59643:21
    at Generator.next (<anonymous>)
    at /Users/hakim/.vscode/extensions/golang.go-0.24.0/dist/goMain.js:59369:71
    at new Promise (<anonymous>)
    at __webpack_modules__.52390.__awaiter (/Users/hakim/.vscode/extensions/golang.go-0.24.0/dist/goMain.js:59365:12)
    at spawnDlvDapServerProcess (/Users/hakim/.vscode/extensions/golang.go-0.24.0/dist/goMain.js:59619:12)
    at /Users/hakim/.vscode/extensions/golang.go-0.24.0/dist/goMain.js:59612:36
    at Generator.next (<anonymous>)
    at fulfilled (/Users/hakim/.vscode/extensions/golang.go-0.24.0/dist/goMain.js:59366:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

Looks like we are not catching the error thrown here

throw new Error('The program attribute must be a directory or .go file in debug and test mode');

We can try to catch the error and start teardown (& print the error message in the DEBUG CONSOLE or popup for better visibility).
Alternatively, before starting the thin adapter from the factory, we can parse the args and fail early.

cc @suzmue

@hyangah hyangah added this to the v0.24.1 milestone Apr 9, 2021
@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/309809 mentions this issue: src/goDebugFactory.ts: send terminated event on server start error

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Debug Issues related to the debugging functionality of the extension. FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

4 participants