Skip to content

Conversation

@bc-lee
Copy link
Contributor

@bc-lee bc-lee commented Oct 23, 2025

Motivation:

See #9274 for context.
The existing logging is insufficient to diagnose hangs in AsyncProcess, so adding more detailed logging around process start, output, and termination should help identify where things are going wrong.

Modifications:

  • Added SWIFTPM_DEBUG_PROCESS_IO environment variable to enable low-level I/O thread debugging without interfering with normal observability output
  • Added processTrackingID (8-character UUID prefix) to uniquely identify each process instance in logs for correlation across multiple concurrent processes
  • Added logProcessIODebug() helper that writes directly to stderr when debug mode is enabled, bypassing all handlers to capture issues even when the observability system has problems
  • Instrumented all critical synchronization points in the I/O thread lifecycle

Result:

After this change, AsyncProcess will log detailed information about process lifecycle events, including when processes are started, when output is received, and when processes terminate. This should provide better visibility into where hangs may be occurring during dependency resolution.

Users experiencing hangs can now run:

SWIFTPM_DEBUG_PROCESS_IO=1 swift package resolve 2>&1 | tee debug.log

See swiftlang#9274 for
context.
The existing logging is insufficient to diagnose hangs in AsyncProcess,
so adding more detailed logging around process start, output,
and termination should help identify where things are going wrong.

- Added `SWIFTPM_DEBUG_PROCESS_IO` environment variable to enable
  low-level I/O thread debugging without interfering with
  normal observability output
- Added `processTrackingID` (8-character UUID prefix) to uniquely
  identify each process instance in logs for correlation
  across multiple concurrent processes
- Added `logProcessIODebug()` helper that writes directly to stderr
  when debug mode is enabled, bypassing all handlers to capture issues
  even when the observability system has problems
- Instrumented all critical synchronization points in the
  I/O thread lifecycle

After this change, AsyncProcess will log detailed information about
process lifecycle events, including when processes are started,
when output is received, and when processes terminate.
This should provide better visibility into where hangs
may be occurring during dependency resolution.

Users experiencing hangs can now run:
```
SWIFTPM_DEBUG_PROCESS_IO=1 swift package resolve 2>&1 | tee debug.log
```
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.

1 participant