Skip to content

VS Code Integrated Terminal Reports Error From Script NOT Being Debugged #4343

Closed
PowerShell/PowerShellEditorServices
#1982
@Abax378

Description

@Abax378

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

Type: Bug

While debugging a script that has a breakpoint set and which raises an error from the cmdlet Start-ThreadJob, the integrated terminal reports an error from a script not being debugged. The error reads:

`ParentContainsErrorRecordException:
Line |
22 | if ($LastHistoryEntry.Id -eq $Global:__LastHistoryId) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The property 'Id' cannot be found on this object. Verify that the property exists.

`

This code appears to be similar to code found here:
microsoft/terminal#14341

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.3.1
PSEdition                      Core
GitCommitId                    7.3.1
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}       
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

1.74.1
1ad8d514439d5077d2b0b7ee64d2ce82a9308e5a
x64

Extension Version

Steps to Reproduce

SETUP

The demo script tries to divide 1 by 0, raising an error.
Download the demo script 'demo_2.ps1' from https://github.com/Abax378/Temp

STEPS TO REPRODUCE

  1. Open the script 'demo_2.ps1' with VS Code. The Powershell extension terminal should be visible (by default).
  2. Kill the Powershell extension terminal. Answer no to the Restart dialog and kill the "Go to output window" dialog.
  3. Close the script.
  4. Close VS Code.
  5. Open VS Code.
  6. Open the script 'demo_2.ps1'. A PowerShell Extension v2022.12.1 terminal should automatically open.
  7. Set a breakpoint on line 29. ( Line 29 reads "If ($arrJobs.Count -gt 0) {" ).
  8. Start debug by placing the cursor anywhere in the script and pressing F5.
  9. An error about Line 22 should appear in the integrated terminal.

Visuals

See 'demo_2_video.mp4' https://github.com/Abax378/Temp

Logs

See 'logs.zip' at https://github.com/Abax378/Temp

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions