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

Cannot use undefined as a parameter for vscode.debug.startDebugging #37559

Closed
changsi-an opened this issue Nov 2, 2017 · 11 comments
Closed

Cannot use undefined as a parameter for vscode.debug.startDebugging #37559

changsi-an opened this issue Nov 2, 2017 · 11 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Milestone

Comments

@changsi-an
Copy link

  • VSCode Version: 1.17.2
  • OS Version: Ubuntu 16.04.3 LTS

Steps to Reproduce:

  1. I am trying to call vscode.debug.startDebugging(undefined, myConfig), but I got the following error if I use undefined as the first parameter.
    screenshot from 2017-11-02 15-19-39

and my debugger session is terminated afterwards.

Notes:

  1. If I call it with
vscode.debug.startDebugging(vscode.workspace.workspaceFolders[0], myConfig) 

then everything works as expected, I could see a debug session launched.

  1. I have put all the attributes defined in the "configurationAttributes" of package.json to the myConfig object (the 2nd parameter), and I declared none of those attributes as required in package.json.

  2. If I just launch a debug configuration using my debugger type from launch.json, everything works as expected.

  3. I tried to debug vscode code, the call to vscode.debug.startDebugging() can actually return successfully. And I do not see any exception thrown from the call. The Cannot read property uri of undefined error seem to be triggered from a later routine.

  4. By vscode.d.ts#L6105 , I should be able to use undefined as the first parameter.

Reproduces without extensions: Unknown. No opportunity to check, because I am developing a extension.

@vscodebot vscodebot bot added the debug Debug viewlet, configurations, breakpoints, adapter issues label Nov 2, 2017
@weinand
Copy link
Contributor

weinand commented Nov 2, 2017

@changsi-an If you pass undefined for the folder parameter to vscode.debug.startDebugging, the debug configuration myConfig must not contain any variables (like ${workspaceFolder}) because variables are resolved against the folder parameter (which is undefined in your case).
So you must pass a folder to vscode.debug.startDebugging if you have a folder. Only in a non-folder setup it makes sense to pass undefined (and in this case a variable like ${workspaceFolder}does not make sense at all).

@isidorn we should fail more gracefully in this case, e.g. by not substituting any variables at all.

@weinand weinand assigned isidorn and unassigned weinand Nov 2, 2017
@weinand weinand added this to the November 2017 milestone Nov 2, 2017
@weinand weinand added the bug Issue identified by VS Code Team member as probable bug label Nov 2, 2017
@changsi-an
Copy link
Author

@weinand I don't have any variables in my myConfig object. All plain strings.

@weinand weinand self-assigned this Nov 2, 2017
@weinand
Copy link
Contributor

weinand commented Nov 2, 2017

@isidorn most likely passing undefined to startDebugging results in the error from above in https://github.com/Microsoft/vscode/blob/1d632ec12cd4ec0fe4f8badfbb743d5bd2807cda/src/vs/workbench/parts/debug/electron-browser/debugService.ts#L905
because the "root" passed to "doCreateProcess" is "undefined".

@weinand weinand removed their assignment Nov 2, 2017
@weinand weinand removed this from the November 2017 milestone Nov 2, 2017
@isidorn isidorn added this to the November 2017 milestone Nov 3, 2017
@isidorn isidorn closed this as completed in 32a8a5c Nov 7, 2017
@isidorn
Copy link
Contributor

isidorn commented Nov 7, 2017

@changsi-an good catch, thanks. You can try it out in vscode insiders in 4 days and let us know how ti works.
@weinand thanks for pointing out the issue

@roblourens
Copy link
Member

vscode.debug.startDebugging(undefined, 'Launch Program'); => nothing happens

vscode.debug.startDebugging(vscode.workspace.workspaceFolders[0], 'Launch Program'); => starts debugging

@roblourens roblourens reopened this Dec 6, 2017
@roblourens
Copy link
Member

And I get this error in devtools: Configuration 'Launch Program' is missing in 'launch.json'.

@weinand
Copy link
Contributor

weinand commented Dec 6, 2017

@roblourens
What you are seeing is the expected behaviour.
if you pass undefined for the workspace folder, then no 'launch.json' and consequently no named launch config can be found. However, in this case it is perfectly fine to pass an launch config object to startDebugging.

The error message Configuration 'Launch Program' is missing in 'launch.json'is misleading because the real problem is that there is no 'launch.json' at all.

@isidorn can we make this clearer?

@isidorn
Copy link
Contributor

isidorn commented Dec 6, 2017

@weinand sure, I have improved the error message to be more precise in the case the launch.json does not exist. Now it simply says "'launch.json' does not exist."

@isidorn isidorn closed this as completed in fe409ae Dec 6, 2017
@roblourens
Copy link
Member

Oh, I get it.

@roblourens roblourens added the verified Verification succeeded label Dec 6, 2017
@changsi-an
Copy link
Author

Is the bug fix released yet? I am still hitting "uri" of undefined error in 1.18.1

@roblourens
Copy link
Member

No, it's in Insiders or the next stable release.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants