Skip to content

Use FlushWriter to ensure traces are flushed#1556

Closed
SteveL-MSFT wants to merge 2 commits into
PowerShell:mainfrom
SteveL-MSFT:tracing-flush
Closed

Use FlushWriter to ensure traces are flushed#1556
SteveL-MSFT wants to merge 2 commits into
PowerShell:mainfrom
SteveL-MSFT:tracing-flush

Conversation

@SteveL-MSFT
Copy link
Copy Markdown
Member

PR Summary

Still seeing random failures particulary on macOS due to traces not being flushed before dsc exits. Doing a bit more research, it seems that macOS itself caches stdio output and thus you need to explicitly flush. Fix here is to use a custom FlushWriter to flushes on every write.

PR Context

Fix #677

Copilot AI review requested due to automatic review settings June 1, 2026 19:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses intermittent trace-related CI failures (notably on macOS) by ensuring tracing output is flushed promptly before the dsc process exits. It does so by wrapping the tracing subscriber’s writer with a custom writer that flushes after writes.

Changes:

  • Added a FlushWriter wrapper implementing std::io::Write that flushes after writing.
  • Added a MakeFlushWriter wrapper implementing tracing_subscriber::fmt::MakeWriter to produce FlushWriter instances.
  • Updated enable_tracing to use the flushing writer for both the default and configured tracing fmt layers.

Comment thread dsc/src/util.rs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@SteveL-MSFT
Copy link
Copy Markdown
Member Author

macOS test still failed, it appears that the flushing is only when using PS based classes, so making change in PS adapter

@SteveL-MSFT SteveL-MSFT closed this Jun 1, 2026
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

Successfully merging this pull request may close these issues.

Tracing is not being flushed before dsc exits

2 participants