C#: Grpc.Tools: Handle regex timeout when parsing protoc output (#36185)

Fix for https://github.com/grpc/grpc/issues/36162

Increase the regex timeout to 1 second. If a timeout occurs then log that the line could not be parsed.

Closes #36185

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36185 from tonydnewell:grpc.tools-regex-timeout 324b301d40
PiperOrigin-RevId: 620767619
pull/36207/head
tony 12 months ago committed by Copybara-Service
parent 03312884dc
commit a087266a27
  1. 16
      src/csharp/Grpc.Tools/ProtoCompile.cs

@ -126,7 +126,7 @@ namespace Grpc.Tools
"javanano", "js", "objc",
"php", "python", "ruby" };
static readonly TimeSpan s_regexTimeout = TimeSpan.FromMilliseconds(100);
static readonly TimeSpan s_regexTimeout = TimeSpan.FromSeconds(1);
static readonly List<ErrorListFilter> s_errorListFilters = new List<ErrorListFilter>()
{
@ -591,12 +591,18 @@ namespace Grpc.Tools
{
foreach (ErrorListFilter filter in s_errorListFilters)
{
Match match = filter.Pattern.Match(singleLine);
try
{
Match match = filter.Pattern.Match(singleLine);
if (match.Success)
if (match.Success)
{
filter.LogAction(Log, match);
return;
}
} catch (RegexMatchTimeoutException)
{
filter.LogAction(Log, match);
return;
Log.LogWarning("Unable to parse output from protoc. Regex timeout.");
}
}

Loading…
Cancel
Save