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

Terminals launched with invalid paths hang during creation and never emit onExit #31301

Closed
azydevelopment opened this issue Jul 24, 2017 · 18 comments · Fixed by #58912
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug terminal General terminal issues that don't fall under another label verified Verification succeeded windows VS Code on Windows issues

Comments

@azydevelopment
Copy link

azydevelopment commented Jul 24, 2017

  • VSCode Version: Code 1.14.2 (cb82feb, 2017-07-19T23:34:09.706Z)
  • OS Version: Windows_NT ia32 10.0.15063
  • Extensions:
Extension Author (truncated) Version
cpptools ms- 0.12.1
csharp ms- 1.11.0

Steps to Reproduce:

  1. Open an empty folder with VSCode
  2. Configure a new MSBuild task
  3. Try building (execute task)

Expected: Fails gracefully somehow
Actual: Just spins forever and never dies until I manually kill the task.

Note: this also happens when I mistype a path or something in the command to a directory that say for example doesn't exist. If the command is wrong in some way, the task will just spin forever.

Reproduces without extensions: Yes/No

@vscodebot vscodebot bot added new release tasks Task system issues labels Jul 24, 2017
@azydevelopment azydevelopment changed the title Task never stopping if command isn't right Task never stopping if command doesn't refer to anything (eg. mispelt) Jul 24, 2017
@azydevelopment azydevelopment changed the title Task never stopping if command doesn't refer to anything (eg. mispelt) Task never stopping if command doesn't refer to anything (eg. mispelled) Jul 24, 2017
@dbaeumer dbaeumer added this to the August 2017 milestone Aug 2, 2017
@dbaeumer dbaeumer added the bug Issue identified by VS Code Team member as probable bug label Aug 2, 2017
@dbaeumer
Copy link
Member

dbaeumer commented Aug 3, 2017

The terminal doesn't send an onExit or any other event in this case so that the task system could determine that the process has finished / died. Steps to reproduce:

  • Windows, no msbuild installed
  • fresh workspace
  • configure task runner
  • select MSBuild from the list of templates
  • F1 > Run Task > Select Build

Observe: the spinner never stops. Could can't even terminate the task.

The reason is that the shell actually fails to execute msbuild however the terminal never send an onExit event. Look at the process explorer there is a lingering vscode process of --type=terminal

capture

@dbaeumer dbaeumer added terminal General terminal issues that don't fall under another label and removed tasks Task system issues labels Aug 3, 2017
@Tyriar
Copy link
Member

Tyriar commented Aug 21, 2017

I upgraded to node-pty@0.7.0 which may improve the problem, if not I'd guess this is related towinpty is not terminating the processes correctly.

@dbaeumer
Copy link
Member

I retested this and it is still happening under Insider today.

@Tyriar
Copy link
Member

Tyriar commented Aug 28, 2017

terminalProcess stalls on this native call: https://github.com/Tyriar/node-pty/blob/a1d161cba7396849116b94d8fa6bb0041a9a7ea6/src/win/pty.cc#L87, meaning this function never returns https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/parts/terminal/node/terminalProcess.ts#L47

Not sure why a Node.js or native exception isn't happening.

@Tyriar
Copy link
Member

Tyriar commented Aug 28, 2017

This has the same root cause as #31770

@Tyriar Tyriar changed the title Task never stopping if command doesn't refer to anything (eg. mispelled) Terminals launched with invalid paths hang and never emit onExit Aug 28, 2017
@Tyriar Tyriar changed the title Terminals launched with invalid paths hang and never emit onExit Terminals launched with invalid paths hang during creation and never emit onExit Aug 28, 2017
@Tyriar Tyriar modified the milestones: September 2017, August 2017 Aug 28, 2017
@Tyriar
Copy link
Member

Tyriar commented Aug 28, 2017

Moving to September as this is a more involved change than I anticipated. More testing in Insiders would be ideal.

@dbaeumer
Copy link
Member

@Tyriar any news on this. Do I need to adopt something here ?

@Tyriar
Copy link
Member

Tyriar commented Sep 26, 2017

No progress, I moved this to September before I knew that I would be out for 2 weeks in September.

@Tyriar Tyriar modified the milestones: September 2017, October 2017 Sep 26, 2017
@Tyriar Tyriar added the windows VS Code on Windows issues label Sep 26, 2017
@Tyriar
Copy link
Member

Tyriar commented Sep 26, 2017

It does look like it affects Windows only.

@mattacosta
Copy link
Contributor

Hmm, I believe that I just came across this while trying to run some tests, and tsc exited with an error code. I was able to reproduce it using this:

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceRoot}/program.js",
            "preLaunchTask": "errorcode"
        }
    ]
}

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "taskName": "errorcode",
            "type": "shell",
            "command": "exit",
            "args": [
                "2"
            ]
        }
    ]
}

Everything works fine if the error code is changed to 0.

@azydevelopment
Copy link
Author

Was this never solved?

@dbaeumer
Copy link
Member

@Tyriar when I last tested this I had the impression that this is still a bug and the terminal hangs (doesn't signal on exit).

@Tyriar
Copy link
Member

Tyriar commented May 23, 2018

Yes, this is still an issue.

@azydevelopment
Copy link
Author

Is this in line to be fixed btw?

@azydevelopment
Copy link
Author

This still happens btw when I'm doing my PowerShell development.....I have to keep restarting all of VSCode because my debugging sessions won't end properly.

@alexr00
Copy link
Member

alexr00 commented Sep 14, 2018

@Tyriar, does this sound like something that will be fixed by conpty?

@Tyriar
Copy link
Member

Tyriar commented Sep 15, 2018

@alexr00 it probably needs a check in node-pty that the file exists before attempting to fire it. It's possible that conpty would fix this but that would only fix it for newer Windows versions when the fix should work when we fallback to winpty.

@Tyriar Tyriar assigned alexr00 and unassigned dbaeumer Sep 17, 2018
@alexr00
Copy link
Member

alexr00 commented Sep 18, 2018

@Tyriar There's already a file_exists check in node-pty before attempting to execute the file. I can't actually reproduce this with a garbage command in my task (ex. "command": "notcmd.exe")
I do think I'm seeing this when I pass garbage in for the args that results in a failure though:

> Executing task: cmd.exe /k c:\users\alros\desktop\nottestscript.bat <
'c:\users\alros\desktop\nottestscript.bat' is not recognized as an internal or external command,
operable program or batch file.`

@Tyriar Tyriar modified the milestones: Backlog, September 2018 Sep 19, 2018
alexr00 added a commit that referenced this issue Sep 19, 2018
@chrmarti chrmarti added the verified Verification succeeded label Sep 28, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 3, 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 terminal General terminal issues that don't fall under another label verified Verification succeeded windows VS Code on Windows issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants