Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cancellation bug causing the wrong exception to be thrown #733

Merged
merged 2 commits into from
Dec 7, 2023

Conversation

nathanwoctopusdeploy
Copy link
Contributor

Background

Fixing a cancellation bug which results in a HalibutClientException being thrown instead of an OperationCancelledException

e.g. https://build.octopushq.com/buildConfiguration/TeamFireAndMotion_OctopusTentacleNet48_SensibleDefaultsChainFullChain/10484945?hideTestsFromDependencies=false&hideProblemsFromDependencies=false&expandBuildTestsSection=true&expandBuildDeploymentsSection=false&expandBuildChangesSection=true&expandPull+Request+Details=true&expandBuildProblemsSection=true

Expected object to match ((x Is TaskCanceledException) OrElse (x Is OperationCanceledException)), but found Halibut.HalibutClientException with message "An error occurred when sending a request to 'https://localhost:51768/', after the request began: The ReadAsync operation was cancelled."
     at Halibut.Transport.SecureListeningClient.HandleError(Exception lastError, Boolean retryAllowed)
     at Halibut.Transport.SecureListeningClient.ExecuteTransactionAsync(ExchangeActionAsync protocolHandler, RequestCancellationTokens requestCancellationTokens)
     at Halibut.HalibutRuntime.SendOutgoingHttpsRequestAsync(RequestMessage request, RequestCancellationTokens requestCancellationTokens)
     at Halibut.HalibutRuntime.SendOutgoingRequestAsync(RequestMessage request, MethodInfo methodInfo, RequestCancellationTokens requestCancellationTokens)
     at Halibut.ServiceModel.HalibutProxyWithAsync.MakeRpcCall(MethodInfo asyncMethod, Object[] args)
     at Halibut.ServiceModel.HalibutProxyWithAsync.InvokeAsyncT[T](MethodInfo asyncMethod, Object[] args)
     at System.Reflection.AsyncDispatchProxyGenerator.InvokeAsync[T](Object[] args)

How to review this PR

Quality ✔️

Pre-requisites

  • I have read How we use GitHub Issues for help deciding when and where it's appropriate to make an issue.
  • I have considered informing or consulting the right people, according to the ownership map.
  • I have considered appropriate testing for my change.

@nathanwoctopusdeploy nathanwoctopusdeploy requested a review from a team as a code owner December 7, 2023 02:29
@@ -63,9 +63,9 @@ public async Task<IScriptOrchestrator> CreateOrchestrator(CancellationToken canc
{
scriptServiceToUse = await DetermineScriptServiceVersionToUse(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
catch (Exception ex) when (cancellationToken.IsCancellationRequested)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@sburmanoctopus sburmanoctopus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nathanwoctopusdeploy nathanwoctopusdeploy enabled auto-merge (squash) December 7, 2023 02:33
@nathanwoctopusdeploy nathanwoctopusdeploy merged commit 0c38a57 into main Dec 7, 2023
48 checks passed
@nathanwoctopusdeploy nathanwoctopusdeploy deleted the sast/fix-cancellation-bug branch December 7, 2023 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants