{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Hosting/issues/1444","repository_url":"https://api.github.com/repos/aspnet/Hosting","labels_url":"https://api.github.com/repos/aspnet/Hosting/issues/1444/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Hosting/issues/1444/comments","events_url":"https://api.github.com/repos/aspnet/Hosting/issues/1444/events","html_url":"https://github.com/aspnet/Hosting/issues/1444","id":329487489,"node_id":"MDU6SXNzdWUzMjk0ODc0ODk=","number":1444,"title":"Deadlock when using Autofac and the ConsoleLifetime on exit","user":{"login":"abe545","id":700612,"node_id":"MDQ6VXNlcjcwMDYxMg==","avatar_url":"https://avatars1.githubusercontent.com/u/700612?v=4","gravatar_id":"","url":"https://api.github.com/users/abe545","html_url":"https://github.com/abe545","followers_url":"https://api.github.com/users/abe545/followers","following_url":"https://api.github.com/users/abe545/following{/other_user}","gists_url":"https://api.github.com/users/abe545/gists{/gist_id}","starred_url":"https://api.github.com/users/abe545/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abe545/subscriptions","organizations_url":"https://api.github.com/users/abe545/orgs","repos_url":"https://api.github.com/users/abe545/repos","events_url":"https://api.github.com/users/abe545/events{/privacy}","received_events_url":"https://api.github.com/users/abe545/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-06-05T14:38:45Z","updated_at":"2018-06-05T15:06:32Z","closed_at":null,"author_association":"NONE","body":"I'm trying to use `Autofac` as my service provider in a console application. Here is a minimal program to repro this:\r\n\r\n```cs\r\nusing System.Threading.Tasks;\r\nusing Autofac.Extensions.DependencyInjection;\r\nusing Microsoft.Extensions.Hosting;\r\n\r\npublic class Program\r\n{\r\n    public static async Task Main(string[] args) => await new HostBuilder()\r\n        .UseServiceProviderFactory(new AutofacServiceProviderFactory())\r\n        .RunConsoleAsync();\r\n}\r\n````\r\n\r\nIt is causing a deadlock because their provider doesn't implement `IDisposable`. Unfortunately, the `ConsoleLifetime` locks until it is disposed, and this only happens if:\r\n1. The `IServiceProvider` implements `IDisposable`\r\n1. The `IServiceProvider` disposes all `IDisposable` instances it creates\r\n\r\n`Autofac` opted not to implement `IDisposable` in the past because `if the service provider is supposed to be disposed, they should have put IDisposable on it` (from https://github.com/autofac/Autofac.Extensions.DependencyInjection/issues/3#issuecomment-242068640). I've opened a new issue where I hope they'll implement it (or allow me to), but I imagine this will be an issue for other DI containers."},"comment":{"url":"https://api.github.com/repos/aspnet/Hosting/issues/comments/394744996","html_url":"https://github.com/aspnet/Hosting/issues/1444#issuecomment-394744996","issue_url":"https://api.github.com/repos/aspnet/Hosting/issues/1444","id":394744996,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDc0NDk5Ng==","user":{"login":"Tratcher","id":1821173,"node_id":"MDQ6VXNlcjE4MjExNzM=","avatar_url":"https://avatars3.githubusercontent.com/u/1821173?v=4","gravatar_id":"","url":"https://api.github.com/users/Tratcher","html_url":"https://github.com/Tratcher","followers_url":"https://api.github.com/users/Tratcher/followers","following_url":"https://api.github.com/users/Tratcher/following{/other_user}","gists_url":"https://api.github.com/users/Tratcher/gists{/gist_id}","starred_url":"https://api.github.com/users/Tratcher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tratcher/subscriptions","organizations_url":"https://api.github.com/users/Tratcher/orgs","repos_url":"https://api.github.com/users/Tratcher/repos","events_url":"https://api.github.com/users/Tratcher/events{/privacy}","received_events_url":"https://api.github.com/users/Tratcher/received_events","type":"User","site_admin":false},"created_at":"2018-06-05T15:06:32Z","updated_at":"2018-06-05T15:06:32Z","author_association":"MEMBER","body":"It wouldn't be much better than StopAsync, the order of event registration would still mean you'd miss some events and logs."}}
{"actor":{"display_login":"Tratcher"}}