Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

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

Ouverte
#39 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
38/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
À l'abandon
Stack technique
powershell
Domaine
backend

Piste de recherche

Start with the Start-ThreadJob reproduction and compare its breakpoint behavior with Start-Job and ForEach-Object -AsJob -Parallel. Read the thread job debugging and job state handling entry points, then trace why the breakpoint does not keep the thread job running for Debug-Job. Done means the reproduction enters the debugger at foo as expected.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Prerequisites
  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.
Steps to reproduce
  • When using Set-PSBreakpoint -Command from a background (child process-based) job, the Set-PSBreakpoint -Command is honored (assuming that the job is already in the Running state - see https://github.com/PowerShell/PowerShell/issues/21258): the breakpoint suspends execution until the Debug-Job call connects.

  • By contrast, with a thread job, that doesn't work: the thread job runs to completion, irrespective of the break point; the same applies to ForEach-Object -AsJob -Parallel.

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

Langage dominant
PowerShell
Étoiles
37
Forks
22
Métriques de merge des PR
Aucune PR mergée en 30 j

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de PowerShell/ThreadJob

Toutes les issues de PowerShell/ThreadJob

Issues similaires

Plus d'issues Backend & API Design

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.