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

Get stderr or last few lines of extension-owned Terminal in API when it crashes? #91016

Closed
rjmholt opened this issue Feb 19, 2020 · 3 comments
Closed
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) terminal General terminal issues that don't fall under another label under-discussion Issue is under discussion for relevance, priority, approach
Milestone

Comments

@rjmholt
Copy link

rjmholt commented Feb 19, 2020

I've read through #78574 and #62103, but please feel free to let me know if this is a duplicate or unfeasible.

Every so often we get an issue opened on the PowerShell extension like this one where the subprocess we start as a terminal crashes before we can log anything.

In those cases, it's currently quite hard to work out why the terminal crashed. We either need the user to run the invocation we pass to VSCode to start the terminal, or get them to record a GIF of the crash when they reproduce it to capture the brief moment the error message is displayed in the terminal before it's cleaned up.

If it were possible for us to get the stderr or the most recent output of the terminal in some way, we'd be able to log the error and probably have a significantly improved rate of error fixing and user satisfaction. I understand that ask is vague and there are performance implications with reading everything as it comes through and so on, but just want to express the general desire to see more than the exit code when a terminal process crashes. And query whether that's:

  1. Already possible
  2. Infeasible
  3. Possibly implementable with some set of caveats
@Tyriar
Copy link
Member

Tyriar commented Feb 21, 2020

So as I understand it we cannot differentiate between stderr and stdout since the messages are just coming over a single pipe, at least without complicating things a bunch (this has been discussed before microsoft/node-pty#71).

As for getting the last few lines of output, right now no extensions can access the terminal output kind of by design. There's a proposed-only API that gets at output (onDidWriteTerminalData) that live share uses but there are performance/security issues with it that we're not willing to accept for general use.

One thought is to expose the terminal buffer similar to TextDocument but the problem there is that the APIs would have to be asynchronous as the terminal doesn't mirror the buffer in the extension host (and definitely should not), but making it async would be inconsistent with TextDocument 😕. If you have any bright ideas on how to expose just the needed context I'm all ears, hard coding a magic number seems bad as people will just keep requesting the number be higher/configurable.

@Tyriar Tyriar added terminal General terminal issues that don't fall under another label under-discussion Issue is under discussion for relevance, priority, approach labels Feb 21, 2020
@pfitzseb
Copy link
Contributor

pfitzseb commented Jul 7, 2020

An alternative might be to add a closeTerminalOnProcessExit: 'always' | 'zero-exit' | 'never' option for window.createTerminal. That way an extension can create a terminal that stays open even if the underlying process dies; the user can then still look at all output.

@Tyriar
Copy link
Member

Tyriar commented Sep 1, 2021

This is essentially asking for #70444

/duplicate

@Tyriar Tyriar closed this as completed Sep 1, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) terminal General terminal issues that don't fall under another label under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

5 participants
@Tyriar @pfitzseb @rjmholt @rzhao271 and others