提交 7b1ed3f3 编写于 作者: H Heejae Chang

made timeout to 7 days so that sleep won't affect it. for master, we should...

made timeout to 7 days so that sleep won't affect it. for master, we should create sleep aware timer to check timeout. for now just 7 days.

also made crash to NFW and info bar.
上级 b1476ba8
......@@ -36,7 +36,7 @@ internal static class RemoteHostOptions
// normally response time is within 10s ms. at most 100ms. if priority is changed to "Normal", most of time 10s ms.
[ExportOption]
public static readonly Option<int> RequestServiceTimeoutInMS = new Option<int>(
nameof(InternalFeatureOnOffOptions), nameof(RequestServiceTimeoutInMS), defaultValue: 10 * 60 * 1000,
nameof(InternalFeatureOnOffOptions), nameof(RequestServiceTimeoutInMS), defaultValue: 7 * 24 * 60 * 60 * 1000 /* 7 day */,
storageLocations: new LocalUserProfileStorageLocation(InternalFeatureOnOffOptions.LocalRegistryPath + nameof(RequestServiceTimeoutInMS)));
// This options allow users to restart OOP when it is killed by users
......
......@@ -9,6 +9,7 @@
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.Execution;
using Microsoft.CodeAnalysis.Extensions;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Remote;
using Microsoft.ServiceHub.Client;
......@@ -192,10 +193,22 @@ private void OnRpcDisconnected(object sender, JsonRpcDisconnectedEventArgs e)
// wait for retry_delayInMS before next try
await Task.Delay(retry_delayInMS, cancellationToken).ConfigureAwait(false);
ReportTimeout(start);
}
// operation timed out, more than we are willing to wait
throw new TimeoutException("RequestServiceAsync timed out");
ShowInfoBar();
// create its own cancellation token and throw it
using (var ownCancellationSource = new CancellationTokenSource())
{
ownCancellationSource.Cancel();
ownCancellationSource.Token.ThrowIfCancellationRequested();
}
// unreachable
throw ExceptionUtilities.Unreachable;
}
private static async Task<Stream> RequestServiceAsync(
......@@ -264,6 +277,14 @@ private static int ReportDetailInfo(IFaultUtility faultUtility)
try
{
// add service hub process.
// we will record dumps for all service hub processes
foreach (var p in Process.GetProcessesByName("ServiceHub.RoslynCodeAnalysisService32"))
{
// include all remote host processes
faultUtility.AddProcessDump(p.Id);
}
var logPath = Path.Combine(Path.GetTempPath(), "servicehub", "logs");
if (!Directory.Exists(logPath))
{
......@@ -303,5 +324,36 @@ private static bool ReportNonIOException(Exception ex)
// catch all exception. not worth crashing VS.
return true;
}
private static readonly TimeSpan s_reportTimeout = TimeSpan.FromMinutes(10);
private static bool s_timeoutReported = false;
private static void ReportTimeout(DateTime start)
{
// if we tried for 10 min and still couldn't connect. NFW some data
if (!s_timeoutReported && (DateTime.UtcNow - start) > s_reportTimeout)
{
s_timeoutReported = true;
// report service hug logs along with dump
WatsonReporter.Report("RequestServiceAsync Timeout", new Exception("RequestServiceAsync Timeout"), ReportDetailInfo);
}
}
private static bool s_infoBarReported = false;
private static void ShowInfoBar()
{
// use info bar to show warning to users
if (CodeAnalysis.PrimaryWorkspace.Workspace != null && !s_infoBarReported)
{
// do not report it multiple times
s_infoBarReported = true;
// use info bar to show warning to users
CodeAnalysis.PrimaryWorkspace.Workspace.Services.GetService<IErrorReportingService>()?.ShowGlobalErrorInfo(
ServicesVSResources.Unfortunately_a_process_used_by_Visual_Studio_has_encountered_an_unrecoverable_error_We_recommend_saving_your_work_and_then_closing_and_restarting_Visual_Studio);
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册