Skip to content

Don't log named pipe connection failures as errors in BuildServerConnection#82609

Merged
jjonescz merged 3 commits into
mainfrom
copilot/fix-ioexception-reporting
Mar 5, 2026
Merged

Don't log named pipe connection failures as errors in BuildServerConnection#82609
jjonescz merged 3 commits into
mainfrom
copilot/fix-ioexception-reporting

Conversation

Copilot AI commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

When connecting to the compiler server fails due to a timeout, pipe ownership mismatch, or other exception, the previous LogException/LogError calls emitted messages prefixed with "Error Error:" or "Error:". This matches the canonical error pattern that MSBuild's Exec task detects in process output, causing it to surface a build error — even though these are transient, recoverable conditions where the compiler falls back gracefully to the command-line tool.

Change

In BuildServerConnection.cs, replace LogException/LogError with plain Log for all three recoverable failure paths in TryConnectToServerAsync. Key diagnostic info (exception type + message) is retained; only the "Error:" prefix is dropped.

- logger.LogException(e, $"Connecting to server timed out after {timeoutMs} ms");
+ logger.Log($"Connecting to server timed out after {timeoutMs} ms: '{e.GetType().Name}' '{e.Message}'");

- logger.LogError("Owner of named pipe is incorrect");
+ logger.Log("Owner of named pipe is incorrect");

- logger.LogException(e, "Exception while connecting to process");
+ logger.Log($"Exception while connecting to process: '{e.GetType().Name}' '{e.Message}'");

LogException/LogError are appropriate for unexpected failures. These connection failures are all handled, recoverable conditions — logging them as errors was misleading.

Original prompt

This section details on the original issue you should resolve

<issue_title>Error Error: 'IOException' 'The semaphore timeout period has expired reported but not really an issue</issue_title>
<issue_description>10.0.103:

During building with Visual Studio 2026 18.3.0 we encounter the following:

EXEC(0,0): Error Error: 'IOException' 'The semaphore timeout period has expired.

It appears that this error is reported, but the build is not failing as a retry is done, but as the error is reported as a canonical error format the exec msbuild task https://learn.microsoft.com/en-us/visualstudio/msbuild/exec-task?view=visualstudio reports an error and stops.

But as this is not really an error as dotnet build is not stopping can the following line be adapted that, it does not report an canonical error

https://github.com/dotnet/roslyn/blob/main/src/Compilers/Shared/BuildServerConnection.cs#L415

</issue_description>

Comments on the Issue (you are @copilot in this section)

@jjonescz > the exec msbuild task https://learn.microsoft.com/en-us/visualstudio/msbuild/exec-task?view=visualstudio reports an error and stops.

I'm not sure what do you mean by this. Where exactly is this Exec task being used? There shouldn't be any Exec task used during normal dotnet build when invoking the C# compiler.</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

When a named pipe connection times out (IOException/TimeoutException),
the previous LogException call generated "Error Error: 'IOException'
'The semaphore timeout period has expired.'" which matches a canonical
error format, causing MSBuild's Exec task to treat it as a build error.

Since connection timeout is a recoverable/transient condition (the
caller retries or falls back to command-line), change to a plain
logger.Log call that preserves the diagnostic info without the
"Error:" prefix.

Co-authored-by: jjonescz <3669664+jjonescz@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix IOException reporting during Visual Studio build Don't log named pipe connection timeout as an error Mar 3, 2026

@jjonescz jjonescz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread src/Compilers/Shared/BuildServerConnection.cs
Comment thread src/Compilers/Shared/BuildServerConnection.cs Outdated
Comment thread src/Compilers/Shared/BuildServerConnection.cs Outdated
…nection.cs

Same issue: pipe ownership failure and general connect exceptions are
also recoverable (both return null → fallback to CLI compiler), so they
should not be logged with an "Error:" prefix that could trigger
MSBuild's canonical error detection.

Co-authored-by: jjonescz <3669664+jjonescz@users.noreply.github.com>
Copilot AI changed the title Don't log named pipe connection timeout as an error Don't log named pipe connection failures as errors in BuildServerConnection Mar 3, 2026
@jjonescz jjonescz requested a review from jaredpar March 3, 2026 18:03
@jjonescz jjonescz marked this pull request as ready for review March 3, 2026 22:47
@jjonescz jjonescz requested a review from a team as a code owner March 3, 2026 22:47
@jjonescz jjonescz requested a review from a team March 4, 2026 16:56
{
pipeStream.Dispose();
logger.LogError("Owner of named pipe is incorrect");
logger.Log("Owner of named pipe is incorrect");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not blocking: Why not log this as an error? It feels like getting in this situation, requires a more specific "step" to get things wrong. i.e. the wrong user opening a named pipe that happens to have the same name, or similar, which we don't really expect to happen accidentally.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess, but we will still fallback to in-process csc invocation, so I think it still makes sense to not fail an Exec task for this, just like we wouldn't fail dotnet build.

@jjonescz jjonescz merged commit c4b4ee0 into main Mar 5, 2026
24 checks passed
@jjonescz jjonescz deleted the copilot/fix-ioexception-reporting branch March 5, 2026 00:42
@dotnet-policy-service dotnet-policy-service Bot added this to the Next milestone Mar 5, 2026
333fred added a commit to 333fred/roslyn that referenced this pull request Mar 9, 2026
* upstream/main: (56 commits)
  [main] Source code updates from dotnet/dotnet (dotnet#82655)
  Update insert.yml to use roslyn-tools for insertions (dotnet#82615)
  Localized file check-in by OneLocBuild Task: Build definition ID 327: Build ID 2921538
  Localized file check-in by OneLocBuild Task: Build definition ID 327: Build ID 2921538
  Reduce allocations during source text diffing (dotnet#82462)
  Localized file check-in by OneLocBuild Task: Build definition ID 327: Build ID 2920904
  Localized file check-in by OneLocBuild Task: Build definition ID 327: Build ID 2920904
  Revert "Throw NotImplementedException when a build errorId is not supported" (dotnet#82638)
  [main] Source code updates from dotnet/dotnet (dotnet#82623)
  Revert System.ValueTuple version update (dotnet#82639)
  Pack enum values
  Track non-blocking PROTOTYPE comments for `Unions` feature in an issue (dotnet#82637)
  Update the build system errors instructions for Visual Studio 2026
  Don't log named pipe connection failures as errors in BuildServerConnection (dotnet#82609)
  Fix resx source generator for less common resx metadata and locations (dotnet#81994)
  Disallow `ref` modifier for a union declaration (dotnet#82632)
  Add IFSharpInlineHintsService2 for displayAllOverride support (dotnet#82629)
  Report errors for union members that are not permitted (dotnet#82626)
  Check language version for union matching and conversions (dotnet#82617)
  [main] Update dependencies from dotnet/arcade (dotnet#82618)
  ...
@jjonescz jjonescz modified the milestones: Next, 18.6 Mar 31, 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.

Error Error: 'IOException' 'The semaphore timeout period has expired reported but not really an issue

4 participants