Set timeout on sending live console log. (#1903)

This commit is contained in:
Tingluo Huang
2022-05-20 21:31:21 -04:00
committed by GitHub
parent d7694774a4
commit 0b73794267
3 changed files with 18 additions and 14 deletions

View File

@@ -1,5 +1,4 @@
using GitHub.DistributedTask.WebApi; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -9,6 +8,7 @@ using System.Net.WebSockets;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using GitHub.DistributedTask.WebApi;
using GitHub.Runner.Sdk; using GitHub.Runner.Sdk;
using GitHub.Services.Common; using GitHub.Services.Common;
using GitHub.Services.WebApi; using GitHub.Services.WebApi;
@@ -274,7 +274,7 @@ namespace GitHub.Runner.Common
} }
} }
if (!pushedLinesViaWebsocket) if (!pushedLinesViaWebsocket && !cancellationToken.IsCancellationRequested)
{ {
if (startLine.HasValue) if (startLine.HasValue)
{ {

View File

@@ -299,7 +299,11 @@ namespace GitHub.Runner.Common
{ {
try try
{ {
await _jobServer.AppendTimelineRecordFeedAsync(_scopeIdentifier, _hubName, _planId, _jobTimelineId, _jobTimelineRecordId, stepRecordId, batch.Select(logLine => logLine.Line).ToList(), batch[0].LineNumber, default(CancellationToken)); // Give at most 60s for each request.
using (var timeoutTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(60)))
{
await _jobServer.AppendTimelineRecordFeedAsync(_scopeIdentifier, _hubName, _planId, _jobTimelineId, _jobTimelineRecordId, stepRecordId, batch.Select(logLine => logLine.Line).ToList(), batch[0].LineNumber, timeoutTokenSource.Token);
}
if (_firstConsoleOutputs) if (_firstConsoleOutputs)
{ {

View File

@@ -48,7 +48,7 @@
<Target Name="Test" DependsOnTargets="GenerateConstant"> <Target Name="Test" DependsOnTargets="GenerateConstant">
<Exec Command="dotnet build Test/Test.csproj -c $(BUILDCONFIG) /p:PackageRuntime=$(PackageRuntime)" ConsoleToMSBuild="true" /> <Exec Command="dotnet build Test/Test.csproj -c $(BUILDCONFIG) /p:PackageRuntime=$(PackageRuntime)" ConsoleToMSBuild="true" />
<Exec Command="dotnet test Test/Test.csproj --no-build --logger:trx" ConsoleToMSBuild="true" /> <Exec Command="dotnet test Test/Test.csproj -c $(BUILDCONFIG) --no-build --logger:trx" ConsoleToMSBuild="true" />
</Target> </Target>
<Target Name="Layout" DependsOnTargets="Clean;Build"> <Target Name="Layout" DependsOnTargets="Clean;Build">