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

Unlike Start-Job, Start-ThreadJob doesn't respect a Set-PSBreakpoint -Command call in connection with Debug-Job #39

Open
3 tasks done
mklement0 opened this issue Sep 3, 2024 · 0 comments

Comments

@mklement0
Copy link

mklement0 commented Sep 3, 2024

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

Write-Verbose -Verbose 'Creating a job that uses `Set-PSBreakpoint -Command foo`'
# NOTE: If you substitute `Start-Job` on the next line, the behavior is as expected.
$job = Start-ThreadJob {

  function foo {
    'hi'
  }
  
  Set-PSBreakpoint -Command foo

  foo

} 

Write-Verbose -Verbose 'Waiting an arbitrary amount of time (e.g., 3 seconds)...'
Start-Sleep 3

Write-Verbose -Verbose 'Initiating debugging...'
$job | Debug-Job

# Clean up.
$job | Remove-Job -Force

Expected behavior

Hit Command breakpoint on 'foo'

At line:3 char:16
+   function foo {
+

That is, the break point should be honored, irrespective of when Debug-Job is invoked,
and the debugger should be entered.

This is indeed how it works with a Start-Job (child process-based) job.

Actual behavior

Debug-Job: /path/to/some.ps1:42
Line |
  19 |  $job | Debug-Job
     |         ~~~~~~~~~
     | The provided job and all child jobs were examined but no jobs were found that could be debugged.  In order to debug a job or child job the job must support debugging and
     | also be in a running state.

That is, the thread job ran to completion without honoring the break point, and the attempt to call Debug-Job came too late.

Error details

No response

Environment data

PowerShell 7.5.0-preview.3

Version

2.0.3, as shipped with PowerShell Core v7.5.0-preview.3

Visuals

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant