-
Notifications
You must be signed in to change notification settings - Fork 511
VS Code Integrated Terminal Reports Error From Script NOT Being Debugged #4343
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
VS Code Integrated Terminal Reports Error From Script NOT Being Debugged #4343
Comments
That error is coming from VS Code's shell integration. Can you try disabling shell integration and try again? /cc @Tyriar seems like an edge case here https://github.com/PowerShell/PowerShellEditorServices/blob/2e456d1ec35132c82a6deae9ffb89ae2e56b5d78/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs#L529-L532, perhaps when |
With Terminal › Integrated › Shell Integration: Enabled, the Line 22 error pops up. With Terminal › Integrated › Shell Integration: Disabled, the Line 22 error does not occur. |
This issue can be reproduced more easily I believe; simply add only the following two lines of code to your PowerShell 7 profile:
(No other code is required in your PowerShell 7 profile.)
This used to work fine before; the issue was only introduced lately. The issue may be caused by line 79 in the file "C:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\contrib\terminal\browser\media\shellIntegration.ps1", shown in the code block below.
If there is no history retrieved on line 39, shown in the code block below, then the
|
I've updated the sample .ps1 file with much simpler code that raises the Line 22 error. The logs are also updated to show the result of running the updated script. @atyourservers - Your method of raising the error seems to have Set-StrictMode in common with my demo script. Your method apparently encounters an error on Line 57, while Set-StrictMode -Version 2.0 in my script encounters an error on Line 22. |
@Abax378, that is because the issue is caused by setting strict mode. Maybe I should have explicitly written that in my previous reply for clarity. Because of strict mode, references to nonexistent properties result in an error message instead of returning The workaround is to simply not set strict mode (it's disabled by default, but if it's enabled you can disable it using Hopefully they can fix this soon. |
@atyourservers - I appreciate you highlighting other paths to a similar error. Let me rearrange your reply a little bit . . .
I definitely agree with that. The purpose of my comment was to highlight for developers trying to solve this problem that there are likely multiple paths to this error (as evidenced by at least three different line numbers with the same code, which in itself seems like a problem if you're having to maintain identical code in multiple modules). I'm sure the developers are smart enough to realize this, but when resources are short, fixing problems sometimes gets limited to the smallest subset of a complaint.
It's easier than that. In many cases, the second attempt at debugging doesn't raise the error since $LastHistoryEntry.Id is populated at that point. That's why it took me a while to figure out when the bug was happening - I had to perform actions that were akin to what you might expect from Clear-History (although Clear-History won't replicate the bug). |
Prerequisites
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
Visual Studio Code Version
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
Visuals
See 'demo_2_video.mp4' https://github.com/Abax378/Temp
Logs
See 'logs.zip' at https://github.com/Abax378/Temp
The text was updated successfully, but these errors were encountered: