-
Notifications
You must be signed in to change notification settings - Fork 28.6k
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
onDidEndTaskProcess's callback is not always fired when a task exits quickly #58828
Comments
This works for me under Windows using the following shell execution task {
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "exit",
"type": "shell",
"command": "exit 1",
"problemMatcher": []
}
]
} code: vscode.tasks.onDidEndTaskProcess((event) => {
console.log(`Exit code ${event.exitCode}`);
}); Output
|
Could you try with a task provided by an extension? Also, I had the issue with a ProcessExecution, not sure if it works with a ShellExecution.... Will have a look |
Same if I contribute the task via a provider. |
I can reproduce under Linux. The reason is that the underlying terminal never signals a @Tyriar any insights why this never fires. Is there a different way for me to know when the process actually started. |
@alexr00 recently touched this area, a37adb6#diff-dc09948028c646a458fac5f5b5d32276 prevents the process ID promise from firing, but only when the terminal exits immediately. |
Interesting, it seems that that is a different bug though (and that my bug report is not as accurate as it should have been). The problem I was having was that killed processes are reported with exitCode == 0, which is obviously wrong. What I suggested as step to reproduce actually hits the other bug you mention (the callback is not fired at all). Please, let me know if you guys would like me to open another issue for that... |
@g-arjones , can you share a task definition that you're seeing this with? |
@alexr00 You could use this...
Let me know if you need further details.. |
I'm also experiencing that. Had to prepend |
@alexr00 Did you get the time to have a look into this? Thank you! |
@g-arjones, I haven't been able to reproduce this with Windows. I'm trying with Linux next. |
@g-arjones, ok I can reproduce with Linux and I'm looking into it. |
@alexr00 thanks a lot! |
The task exit code being 0 on Linux has been occurring since at least the beginning of September(went back and checked) so that isn't related to the change I made. This appears to be an upstream issue since 0 is the exit code that we're getting from node-pty. |
@alexr00 How about the event not being fired if the process ends too quickly? |
It's a different issue, but it also wasn't introduced recently. I'll keep investigating. |
And that tasks wait for terminal process ready before checking to see if task process ended to fire Related #58828
@g-arjones, as you can see I'm working on a change for the exit event not being fired. |
Yes, I can see that. Thank you very much for the effort. 😄
Strictly speaking, on POSIX systems, if the process is killed there is no exit code (or, to be precise, the exit code portion of the exit status is unset). But the point is: returning 0 as exit code for processes that did not really exit is misleading for extension authors (and would be considered a bug by some, specially given that zero indicates sucess in this context). What shells typically do is return something greater than 127 to indicate that a process was signaled. So, couldn't you do something like that (setting exit code to an arbitrary high number) here? node-pty provides the information you need for that.. On Windows that is a non-issue because the code is never 0 for terminated processes anyway... |
We could also use |
Sounds good... |
@Tyriar, what is your preference on how we handle exit codes? |
And that tasks wait for terminal process ready before checking to see if task process ended to fire Related #58828
New issue for the zero exit code: #62043. |
Steps to Reproduce:
vscode.tasks.onDidEndTaskProcess
vscode.tasks.executeTask
APIevent.exitCode
passed to the callback (should be non zero)Does this issue occur when all extensions are disabled?: Yes
The text was updated successfully, but these errors were encountered: