Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce intermittent tracing/test failures by ensuring pending output is flushed and giving trace/log writers a brief window to complete before the dsc process terminates.
Changes:
- Introduces a custom
util::exit(code)that flushes stdout/stderr and sleeps briefly before terminating the process. - Updates
dsc/src/main.rsto use the newexit()instead ofstd::process::exit.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
dsc/src/util.rs |
Adds a custom process-exit helper intended to improve trace/output reliability at shutdown. |
dsc/src/main.rs |
Switches the CLI entrypoint to call the new exit helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
This PR addresses intermittent tracing test failures by attempting to ensure pending stdout/stderr output is written before the dsc process terminates.
Changes:
- Introduces a custom
util::exit()that flushes stdio and sleeps briefly before exiting. - Switches
main.rsto use the newutil::exit()instead ofstd::process::exit.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| dsc/src/util.rs | Adds a custom process exit helper that flushes stdio and delays before exiting. |
| dsc/src/main.rs | Routes process termination through the new util exit helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
297e053 to
9369326
Compare
| /// * `code` - The exit code to use when exiting the process | ||
| pub fn exit(code: i32) -> ! { | ||
| // Small delay to ensure async writes complete | ||
| std::thread::sleep(std::time::Duration::from_millis(50)); |
There was a problem hiding this comment.
👀 Seems like a workaround more than a solution...is there no way to wait on the async threads (with a timeout too so we don't hang)?
There was a problem hiding this comment.
It looks like I can call https://docs.rs/tokio/latest/tokio/runtime/struct.Runtime.html#method.shutdown_timeout
There was a problem hiding this comment.
Actually, I can't use that outside of an async task running within the runtime. And it looks like tokio itself doesn't provide a way to wait tokio-rs/tokio#5369
So this workaround seems like the only approach
There was a problem hiding this comment.
I take it back, it looks like a WorkerGuard flushes when dropped (https://docs.rs/tracing-appender/latest/tracing_appender/non_blocking/struct.WorkerGuard.html), so need to keep the guard and drop on exit.
There was a problem hiding this comment.
Spent too much time on this. Using a guard doesn't work because we're also using Indicatif crate for writing progress bars which makes the guard not work. So I'm back to having a short delay to allow async traces to get written as Indicatif repo says they don't support their own guard yet.
f5cc746 to
39a3cb7
Compare
There was a problem hiding this comment.
Pull request overview
This PR aims to make tracing output deterministic at process shutdown by introducing a custom exit() path that drops a stored tracing guard and flushes stdout/stderr before terminating, reducing intermittent tracing-test flakes.
Changes:
- Add a global
TRACING_GUARDand store the tracing default guard duringenable_tracing(). - Introduce
util::exit(code)to drop the stored guard and flush stdout/stderr beforestd::process::exit. - Update
main.rsto use the newexit()and simplify someutil::-qualified calls.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| dsc/src/util.rs | Adds global tracing guard storage and a custom exit() that drops the guard + flushes stdio. |
| dsc/src/main.rs | Switches to util::exit() and updates imports/qualifiers to match the new shutdown behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
39a3cb7 to
a2722a4
Compare
PR Summary
There's a race condition where a trace may be received before it is written. This shows up in tracing tests which fail intermittently due to the expected trace not showing up.
Fix is to ensure that stderr and stdout is flushed and give async threads time before
dscprocess exits by having customexit()function that drops the tracing guard which flushes and then also flush stdout/stderr.Some syntax changes to be consistent removing the crate name with
usestatements.