Handle regex timeout in grpc.tools

pull/36185/head
tony 11 months ago
parent 8013ffe965
commit 324b301d40
  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