You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix IIS/Windows Service console race condition (#7691) (#7793) (#7810)
* Fix IIS/Windows Service console race condition (#7691)
- Detect when running in IIS/Windows Service environments where Console.Out
and Console.Error are redirected to the same StreamWriter.Null singleton
- Skip console output entirely in these environments to prevent race conditions
that cause IndexOutOfRangeException and cascade failures
- Improve DefaultLogger error handling to prevent feedback loops
- Add unit tests for non-console scenarios
The race condition occurs because:
1. IIS/Services redirect both Console.Out and Console.Error to StreamWriter.Null
2. StreamWriter.Null is a singleton, not thread-safe for concurrent access
3. Multiple threads writing to both streams cause IndexOutOfRangeException
4. Console output goes nowhere in these environments anyway
Fixes#7691
* Refine console detection and simplify error handling
- Make console detection more precise: only skip output when both Console.Out
AND Console.Error point to StreamWriter.Null (the exact race condition scenario)
- Remove unnecessary try-catch in DefaultLogger.Print() since Tell() is unlikely to throw
- Keep improved error message for debugging when logger is not initialized
0 commit comments