Skip to content

VS Code does not run PowerShell jobs correctly #120

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

Closed
marksrasmussen opened this issue Mar 17, 2016 · 17 comments
Closed

VS Code does not run PowerShell jobs correctly #120

marksrasmussen opened this issue Mar 17, 2016 · 17 comments
Labels
Issue-Bug A bug to squash.

Comments

@marksrasmussen
Copy link

$test = {
  function makeform {     
          [void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")    
          [System.Windows.Forms.Application]::EnableVisualStyles();    

          $form = New-Object Windows.Forms.Form    
          $form.Text = 'Test Form'    

          $form.Add_Shown({$form.Activate()})    
          $form.ShowDialog()    
  }
}

Start-Job { makeform } -InitializationScript $test
---------------------------------
PS C:\WINDOWS\system32> D:\AMS\scripts\MaybeBug.ps1
Id     Name            PSJobTypeName   State         HasMoreData     Location             Command               
--     ----            -------------   -----         -----------     --------             -------               
7      Job7            BackgroundJob   Running       True            localhost             makeform

----------------------------------
Visual Stu
Id     Name            PSJobTypeName   State         HasMoreData     Location             Command                  
--     ----            -------------   -----         -----------     --------             -------                  
1      Job1            BackgroundJob   Failed        False           localhost             makeform    
@daviwil
Copy link
Contributor

daviwil commented Mar 17, 2016

Hey @marksrasmussen, there may be some behavior we need to add to support PowerShell jobs. Thanks for the example script! I'll try to get this fixed for a future release.

@daviwil daviwil added the Issue-Bug A bug to squash. label Mar 17, 2016
@daviwil daviwil added this to the Backlog milestone Mar 17, 2016
@daviwil daviwil changed the title VSCode vs PS_IDE run behaviors differ: Start-Job {makeform} VS Code does not run PowerShell jobs correctly Mar 17, 2016
@mcmiv413
Copy link

Just wanted to include some error information, I got bit by this bug today.

Start-Job -Name testjob2 -ScriptBlock {get-process -Name "Code" | select processname,id,starttime}

receive-job -name testjob2

[localhost] The background process reported an error with the following message:
Cannot process an element with node type "Text".
Only Element and EndElement node types are supported.at
System.Management
.Automation
.Remoting
.OutOfProcessUtils
.ProcessData(String data, DataProcessingDelegates callbacks).
+ CategoryInfo : OpenError: (localhost:String) [], PSRemotingTransportException
+ FullyQualifiedErrorId : 2100,PSSessionStateBroken

@daviwil
Copy link
Contributor

daviwil commented Apr 18, 2016

What a strange error... Not sure if it's a job problem or something else. Will look into it!

@JanCervak
Copy link

The issue is still present in the current marketplace release (0.6.1 - 5/17/2016).

@rkeithhill
Copy link
Contributor

Sorry, this item is still on the backlog. To keep track of the status of this bug, keep an eye on the Milestone field to the upper right.

Hopefully we can get it at least figured out for the next release and possibly fixed if the "fix" is simple enough. :-) I think we are shooting for a faster release frequency which may help as well.

@maximpashuk
Copy link

Having the same issue as @mcmiv413, my integration scripts actively using powershell jobs, so this will be nice to have full support of jobs in vscode-powershell.

@pcgeek86
Copy link
Contributor

@rkeithhill @daviwil Just circling back on this to clean up. I am able to successfully invoke PowerShell Background Jobs on Mac OS X from the latest version of the VSCode PowerShell Extension. I'm currently running:

PS /Users/tsulli/Amazon> code -v
1.11.2
6eaebe3b9c70406d67c97779468c324a7a95db0e
PS /Users/tsulli/Amazon> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.0-alpha
PSEdition                      Core
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   3.0.0.0
GitCommitId                    v6.0.0-alpha.18
CLRVersion
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

screen shot 2017-04-22 at 7 19 49 pm

Cheers,
Trevor Sullivan

@GoateePFE
Copy link

On MacOS with VSCode 1.15.1 and PowerShell Extension version 1.4.1 and PowerShell Core Beta 5...
I am able to start a job from the terminal window or by pressing F8 on a line in the editor. However, if I use the F8 method, then the terminal window does not respond until I press ENTER an additional time. If I run Start-Job in the terminal window directly then the prompt returns immediately. The same behavior is true when using the "&" appended at the end of the line to start a job.

@TylerLeonhardt
Copy link
Member

Hi @GoateePFE, can you elaborate on what you mean by the F8 method?

@pcgeek86
Copy link
Contributor

pcgeek86 commented Dec 8, 2017

@tylerl0706 In the Windows PowerShell Integrated Scripting Editor (ISE), F8 became the standard shortcut to run the "current line" that the cursor is on (if there is no editor selection) or "current selection" (if there is an editor selection).

So, I'm guessing that what @GoateePFE means by "F8 method" is that he's simply putting the cursor on a line with a Start-Job command and simply hitting F8 to invoke that line, as opposed to manually typing the Start-Job command into the VSCode Integrated Terminal.

@GoateePFE
Copy link

@tylerl0706 The comments of @pcgeek86 are correct.

@TylerLeonhardt
Copy link
Member

Thanks for that guys! I can repro exactly what @pcgeek86 said. So something fixed the other scenarios but this one is still broken. We'll have to look into this.

Thanks for the update!

@rkeithhill
Copy link
Contributor

rkeithhill commented Dec 9, 2017

I bet the issue that @GoateePFE is seeing is the same bug as PowerShell/PowerShellEditorServices#554. It only happens on non-Windows systems. I know right where the issue lies (documented in the aforementioned issue and my first attempt to fix it - PowerShell/PowerShellEditorServices#557).

@TylerLeonhardt
Copy link
Member

@rkeithhill this issue should be fixed now with PowerShell/PowerShellEditorServices#592

But it also looks like @SeeminglyScience might be addressing an issue with that PR?

@rkeithhill
Copy link
Contributor

Yup, I'd say the original issue is fixed. Close it.

@TylerLeonhardt
Copy link
Member

Awesome! Keep your eyes out for this in the next release!

@ohadschn
Copy link

ohadschn commented Mar 7, 2019

Regarding the The background process reported an error with the following message: Cannot process an element with node type "Text". Only Element and EndElement node types are supported error see: https://stackoverflow.com/questions/33936510/start-job-including-custom-cmdlet-terminates-with-strange-error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

10 participants