Title: Unlike `Start-Job`, `Start-ThreadJob` doesn't respect a `Set-PSBreakpoint -Command` call in connection with `Debug-Job` · Issue #39 · PowerShell/ThreadJob · GitHub
Open Graph Title: Unlike `Start-Job`, `Start-ThreadJob` doesn't respect a `Set-PSBreakpoint -Command` call in connection with `Debug-Job` · Issue #39 · PowerShell/ThreadJob
X Title: Unlike `Start-Job`, `Start-ThreadJob` doesn't respect a `Set-PSBreakpoint -Command` call in connection with `Debug-Job` · Issue #39 · PowerShell/ThreadJob
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-PS...
Open Graph 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 backgrou...
X 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 backgrou...
Opengraph URL: https://github.com/PowerShell/ThreadJob/issues/39
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unlike `Start-Job`, `Start-ThreadJob` doesn't respect a `Set-PSBreakpoint -Command` call in connection with `Debug-Job`","articleBody":"### Prerequisites\r\n\r\n- [X] Write a descriptive title.\r\n- [X] Make sure you are able to repro it on the latest version\r\n- [X] Search the existing issues.\r\n\r\n### Steps to reproduce\r\n\r\n* 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.\r\n\r\n* 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`.\r\n\r\n```powershell\r\nWrite-Verbose -Verbose 'Creating a job that uses `Set-PSBreakpoint -Command foo`'\r\n# NOTE: If you substitute `Start-Job` on the next line, the behavior is as expected.\r\n$job = Start-ThreadJob {\r\n\r\n function foo {\r\n 'hi'\r\n }\r\n \r\n Set-PSBreakpoint -Command foo\r\n\r\n foo\r\n\r\n} \r\n\r\nWrite-Verbose -Verbose 'Waiting an arbitrary amount of time (e.g., 3 seconds)...'\r\nStart-Sleep 3\r\n\r\nWrite-Verbose -Verbose 'Initiating debugging...'\r\n$job | Debug-Job\r\n\r\n# Clean up.\r\n$job | Remove-Job -Force\r\n```\r\n\r\n\r\n### Expected behavior\r\n\r\n```console\r\nHit Command breakpoint on 'foo'\r\n\r\nAt line:3 char:16\r\n+ function foo {\r\n+\r\n```\r\n\r\nThat is, the break point should be honored, irrespective of when `Debug-Job` is invoked, \r\nand the debugger should be entered.\r\n\r\nThis is indeed how it works with a `Start-Job` (_child process_-based) job.\r\n\r\n\r\n### Actual behavior\r\n\r\n```console\r\nDebug-Job: /path/to/some.ps1:42\r\nLine |\r\n 19 | $job | Debug-Job\r\n | ~~~~~~~~~\r\n | 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\r\n | also be in a running state.\r\n```\r\n\r\nThat is, the thread job ran to completion without honoring the break point, and the attempt to call `Debug-Job` came too late.\r\n\r\n### Error details\r\n\r\n_No response_\r\n\r\n### Environment data\r\n\r\n```PowerShell\r\nPowerShell 7.5.0-preview.3\r\n```\r\n\r\n\r\n### Version\r\n\r\n2.0.3, as shipped with PowerShell Core v7.5.0-preview.3\r\n\r\n### Visuals\r\n\r\n_No response_","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2024-09-03T23:39:11Z","url":"https://github.com/PowerShell/ThreadJob/issues/39"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3c791958-34ac-e662-2ed3-a61e139bfe56 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A842:10BEBB:11CB822:192A326:6AFCD8C2 |
| html-safe-nonce | 308f0eec58243c04e1f42c0796e41f64e8b2218cbf22426b7fe57b895558ffad |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODQyOjEwQkVCQjoxMUNCODIyOjE5MkEzMjY6NkFGQ0Q4QzIiLCJ2aXNpdG9yX2lkIjoiMTk4NTQ0MzMyMTIxOTk2MzA3NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 644d11281c7e703af33aebd421905636762121b6a0ad8d0d3090aa06a47b124f |
| hovercard-subject-tag | issue:2503998349 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/ThreadJob/39/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2f97168cf74f79fbb7b0a9c3a586e83ac6a8fc0802e948c56c753bdeaf293eb7/PowerShell/ThreadJob/issues/39 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2f97168cf74f79fbb7b0a9c3a586e83ac6a8fc0802e948c56c753bdeaf293eb7/PowerShell/ThreadJob/issues/39 |
| og:image:alt | 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 backgrou... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5b7bc7e41e0a604bbdb5035c7ed9620c2d28b9c8a18747182e2262a75abfd91 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/ThreadJob git https://github.com/PowerShell/ThreadJob.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 265675369 |
| octolytics-dimension-repository_nwo | PowerShell/ThreadJob |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 265675369 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/ThreadJob |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ff5022cc3aa767e6115451d9c322dd975506d40e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width