If a Connect Diagnostic Port doesn't explicitly call DisconnectNamedPipe before closing the handle, the error handling in the runtime will erroneously treat this as a generic error rather than a hangup. The if statement currently only marks ERROR_PIPE_NOT_CONNECTED as a hangup, but should also treat ERROR_PIPE_BROKEN as a hangup. The current error path also does not reset the connection, so the cache is still there on subsequent loops through IpcStreamFactory::GetNextAvailableStream which leaves us waiting on handles that no longer are attached to anything.
The fix is simple and twofold: reset connections on the error path & map ERROR_PIPE_BROKEN to the hangup state rather than error state. The PR is incoming.
CC @tommcdon @sywhang @noahfalk @jander-msft