Skip to content

Commit

Permalink
tools: Ignore OverflowException in Octokit response deserialization
Browse files Browse the repository at this point in the history
Workaround for octokit/octokit.net#2927

Fortunately we don't actually need the response for any of these
operations.
  • Loading branch information
jskeet committed Jun 6, 2024
1 parent 5d53acd commit 66981db
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public async Task StartAsync()
string message = string.IsNullOrEmpty(buildUrl) ?
"The release build has started, but the build log URL could not be determined."
: $"The release build has started; the log can be viewed [here]({buildUrl}).";
await _pullRequest.AddComment(_client, message);

await CatchOctokitOverflow(_pullRequest.AddComment(_client, message), "adding comment");
}

/// <summary>
Expand All @@ -61,9 +61,9 @@ public async Task FinishAsync(bool buildSucceeded, string details)
? ("Release build succeeded.", "autorelease: published")
: ("The release build failed! Please investigate!", "autorelease: failed");
message += "\n" + details;
await _pullRequest.AddComment(_client, message);
await _pullRequest.AddLabel(_client, label);
await _pullRequest.RemoveLabel(_client, "autorelease: tagged");
await CatchOctokitOverflow(_pullRequest.AddComment(_client, message), "adding comment");
await CatchOctokitOverflow(_pullRequest.AddLabel(_client, label), "adding label");
await CatchOctokitOverflow(_pullRequest.RemoveLabel(_client, "autorelease: tagged"), "removing label");
}

public static async Task<PublishReporter> Create()
Expand Down Expand Up @@ -101,4 +101,17 @@ string GetRequiredEnvironmentVariable(string variable)
return value;
}
}

// Workaround for https://github.com/octokit/octokit.net/issues/2927 and similar issues
private static async Task CatchOctokitOverflow(Task task, string description)
{
try
{
await task;
}
catch (OverflowException e) when (e.StackTrace?.Contains("Octokit.Internal.JsonHttpPipeline.DeserializeResponse") == true)
{
Console.WriteLine($"Ignoring OverflowException from Octokit when {description}");
}
}
}

0 comments on commit 66981db

Please sign in to comment.