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

SubscriberClientImpl.DisposeAsync throws exception #13647

Open
anabnich opened this issue Oct 3, 2024 · 1 comment · May be fixed by #13651
Open

SubscriberClientImpl.DisposeAsync throws exception #13647

anabnich opened this issue Oct 3, 2024 · 1 comment · May be fixed by #13651
Assignees

Comments

@anabnich
Copy link

anabnich commented Oct 3, 2024

Environment details

  • OS: Mac
  • .NET version: .NET 8
  • Package name and version: 3.18.0

Steps to reproduce

  1. Create DI container
  2. Register a pubsub subscription
  3. Throw an exception in a class which is instantiated via DI injection.

result:

Unhandled exception. System.InvalidOperationException: Can only stop a started instance.
at Google.Api.Gax.GaxPreconditions.CheckState(Boolean condition, String message)
at Google.Cloud.PubSub.V1.SubscriberClientImpl.StopAsync(CancellationToken hardStopToken)
at Google.Cloud.PubSub.V1.SubscriberClient.StopAsync(TimeSpan timeout)
at Google.Cloud.PubSub.V1.SubscriberClientImpl.DisposeAsync()
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.DisposeAsync()
--- End of stack trace from previous location ---
at Microsoft.Extensions.Hosting.Internal.Host.g__DisposeAsync|21_0(Object o)
at Microsoft.Extensions.Hosting.Internal.Host.DisposeAsync()
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at WebApplication.Program.Main(String[] args)

Expected result:
DisposeAsync does not throw an exception if it hasn't been started yet. The constructor exception will be caught in DI container and logged.

@jskeet
Copy link
Collaborator

jskeet commented Oct 3, 2024

Thanks for reporting this. We'll look into it.

amanda-tarafa added a commit to amanda-tarafa/google-cloud-dotnet that referenced this issue Oct 3, 2024
We preserve the stop behaviour: stop does throw if it's called before start.

Fixes googleapis#13647
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 a pull request may close this issue.

3 participants