test: verify automatic flush on exit without Stop-Sentry#138
Draft
jamescrosswell wants to merge 3 commits into
Draft
test: verify automatic flush on exit without Stop-Sentry#138jamescrosswell wants to merge 3 commits into
jamescrosswell wants to merge 3 commits into
Conversation
Add a regression test for #38 that runs a child process which starts Sentry, captures a message, and exits WITHOUT calling Stop-Sentry. It asserts the process exits cleanly within a timeout (no hang, as in sentry-dotnet#3141) and that the captured event is still delivered. A file-writing transport (FileTransport in utils.ps1) is used so delivery can be observed from the parent after the child exits, without networking/ports in CI. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
When powershell.exe (Windows PowerShell) is spawned from a pwsh host, the inherited PSModulePath points only at PowerShell Core's module directories, preventing autoload of Microsoft.PowerShell.Utility (Import-PowerShellDataFile), which the module's psm1 uses during import. Reset to the machine default under Desktop edition so built-in modules are discoverable. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Windows PowerShell 5.1 does not reliably populate .ExitCode on the object returned by `Start-Process -PassThru` after WaitForExit(timeout). Start the child via System.Diagnostics.Process instead, reading stdout/stderr async to avoid pipe-buffer deadlocks, so the exit code is available on both editions. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
| try { | ||
| $exited = $proc.WaitForExit($TimeoutSeconds * 1000) | ||
| if (-not $exited) { | ||
| try { $proc.Kill() } catch {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a regression test for automatic flush on process exit. After #85 removed the workaround that disabled the .NET SDK's
AppDomain.ProcessExitflush hook (the workaround existed because that hook used to hang/crash — getsentry/sentry-dotnet#3141, fixed in getsentry/sentry-dotnet#4323), a script should no longer need to callStop-Sentryfor events to be delivered.The test launches a child process that:
Stop-Sentry.The parent then asserts the child:
A
FileTransport(added totests/utils.ps1) serializes envelopes to disk so delivery is observable from the parent after the child exits, avoiding networking/open ports in CI.The main goal is to confirm this holds on the Windows CI matrices (Windows PowerShell 5.1 / net462 — the platform the synchronous transport design targets), which we couldn't validate locally.
Closes #38
#skip-changelog