Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Capture and report Extension Terminal exit code on startup failure#5526

Merged
JustinGrote merged 1 commit into
mainPowerShell/vscode-powershell:mainfrom
andyleejordan/investigate-5031-startup-timeoutPowerShell/vscode-powershell:andyleejordan/investigate-5031-startup-timeoutCopy head branch name to clipboard
Jun 18, 2026
Merged

Capture and report Extension Terminal exit code on startup failure#5526
JustinGrote merged 1 commit into
mainPowerShell/vscode-powershell:mainfrom
andyleejordan/investigate-5031-startup-timeoutPowerShell/vscode-powershell:andyleejordan/investigate-5031-startup-timeoutCopy head branch name to clipboard

Conversation

@andyleejordan

Copy link
Copy Markdown
Member

Summary

Improves diagnostics for #5031. When the PowerShell process exits during
startup — as in that report, where pwsh terminated ~3 seconds after spawn — we
discarded the Extension Terminal's exit status and surfaced a generic
"PowerShell Language Server process didn't start!" message. The logs there show
a fast process exit, not a slow start, so neither the 60s version-details
timeout nor the 4-minute session-file wait was ever the culprit, and we had no
way to know why pwsh died.

Changes

  • src/process.ts: capture terminal.exitStatus in onTerminalClose
    before disposing the process, expose it via a new getExitStatus() getter,
    and include the exit code in the warning log.
  • src/session.ts: in handleFailedProcess, report
    exited with code: N before connecting! Check the PowerShell output for errors. for non-zero codes, falling back to the original
    "...didn't start!" wording when the code is undefined (the user/VS Code
    closed the terminal, or it timed out).
  • test/core/process.test.ts (new): covers no-status-before-close,
    capture + log on close, and ignoring unrelated terminals' close events.

This does not fix the underlying exit — that's almost certainly environmental
(AV/EDR, profile, module load) — so it intentionally does not auto-close
#5031. It turns an undiagnosable report into a diagnosable one by asking
reporters for the exit code.

Notes

Drafted by Copilot (Claude Opus 4.8).

When the PowerShell process exits during startup -- as in #5031, where
pwsh terminated ~3 seconds after spawn -- we threw away the terminal's
exit status and surfaced a generic "PowerShell Language Server process
didn't start!" message. That's unactionable: the logs show a *fast
process exit*, not a slow start, and we had no way to know *why* pwsh
died.

We now capture `terminal.exitStatus` in `onTerminalClose` before
disposing the process, expose it via `getExitStatus()`, and include a
non-zero exit code in both the log warning and the failure notification
("...exited with code: N before connecting!"). When the code is
`undefined` (the user or VS Code closed the terminal, or it simply timed
out) we fall back to the original wording. I don't claim this fixes the
underlying exit -- that's almost certainly environmental (AV/EDR,
profile, module load) -- but it turns an undiagnosable report into a
diagnosable one.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@JustinGrote JustinGrote left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, might be useful when submitting logs, IDK.

@JustinGrote JustinGrote left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andyleejordan you need to switch this from draft.

@andyleejordan

Copy link
Copy Markdown
Member Author

Ah, this one spawned out of a "Copilot thinks it can fix this bug" until I went and said, no I already fixed that lol but I didn't know we had TerminalExitStatus and I was undedcided if it was worth adding...Looking at it yeah why not include the exit code?

@andyleejordan andyleejordan marked this pull request as ready for review June 18, 2026 17:47
Copilot AI review requested due to automatic review settings June 18, 2026 17:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves startup failure diagnostics by capturing and reporting the Extension Terminal's exit code when the PowerShell process terminates before connecting to the LSP client. Previously, users saw only a generic "PowerShell Language Server process didn't start!" message, making it impossible to diagnose the underlying cause. Now, a non-zero exit code is surfaced in both the warning log and the user-facing error message.

Changes:

  • Capture the terminal's exitStatus in onTerminalClose before disposal and expose it via a getExitStatus() getter on PowerShellProcess.
  • Use the captured exit code in handleFailedProcess to produce a more actionable error message when the exit code is non-zero.
  • Add a new test file test/core/process.test.ts covering exit status capture, logging, and the unrelated-terminal guard.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/process.ts Adds exitStatus field, getExitStatus() getter, captures exit status in onTerminalClose, and enriches the warning log with the exit code.
src/session.ts Reads the exit code from the process in handleFailedProcess and produces a code-specific error message for non-zero exits.
test/core/process.test.ts New test file verifying exit status is undefined before close, captured/logged on close, and ignored for unrelated terminals.

Comment thread src/session.ts
shouldUpdate = false;
// If the process terminated before connecting, VS Code gives us the
// terminal's exit code, which is far more actionable than a generic
// failure. A `undefined` code means it timed out or was closed
@github-actions github-actions Bot mentioned this pull request Jun 18, 2026
@JustinGrote JustinGrote merged commit 9e46c55 into main Jun 18, 2026
9 checks passed
@JustinGrote JustinGrote deleted the andyleejordan/investigate-5031-startup-timeout branch June 18, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.