{"id":16532452,"url":"https://github.com/sayan751/netcore-httpsys-object-disposed-repro","last_synced_at":"2025-03-03T10:44:26.127Z","repository":{"id":50486641,"uuid":"518323159","full_name":"Sayan751/netcore-httpsys-object-disposed-repro","owner":"Sayan751","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-29T13:04:25.000Z","size":5221,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-13T21:43:49.323Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sayan751.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-27T05:37:31.000Z","updated_at":"2022-07-29T12:50:33.000Z","dependencies_parsed_at":"2022-09-24T12:47:04.732Z","dependency_job_id":null,"html_url":"https://github.com/Sayan751/netcore-httpsys-object-disposed-repro","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sayan751%2Fnetcore-httpsys-object-disposed-repro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sayan751%2Fnetcore-httpsys-object-disposed-repro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sayan751%2Fnetcore-httpsys-object-disposed-repro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sayan751%2Fnetcore-httpsys-object-disposed-repro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sayan751","download_url":"https://codeload.github.com/Sayan751/netcore-httpsys-object-disposed-repro/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241652945,"owners_count":19997575,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T18:12:41.567Z","updated_at":"2025-03-03T10:44:26.102Z","avatar_url":"https://github.com/Sayan751.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# netcore-httpsys-object-disposed-repro\r\n\r\nThis repository is a reproduction of this issue: https://github.com/dotnet/aspnetcore/issues/42608.\r\n\r\nThe content of this repo is divided into 3 sections: hosting service, e2e tests, and SPA sources.\r\n\r\n## SPA sources\r\n\r\nTwo SPAs can be found under the `SPA-sources` directory.\r\nThe apps are already built and the distributable can be found under the `hosting-service\\Content` directory; a sub-directory for every app.\r\nIf you make any changes in the app, use `npm run build` to build the apps, which will put the new distributable correctly under the `hosting-service\\Content` directory.\r\n\r\n## Hosting service\r\n\r\nThe hosting service, located under the `hosting-service` directory, uses a self-signed certificate to use the domain name `gh.repro.sp.dev`.\r\nThis certificate is included in this repository as `gh.repro.sp.dev.pfx`.\r\n\r\nAssuming Windows Environment:\r\n- Make sure to add the certificate in the cert store (Local Computer/My).\r\n- Add the `sslcert` by executing: `netsh http add sslcert hostnameport=gh.repro.sp.dev:7048 certhash=3bed9da4b7d762b3c00850865a05c647b4536fdd \"appid={80AC362F-9C0D-4FB9-A284-03B2364BF60B}\" certstorename=my`. You might need administrator privilege for that.\r\n- Add the following to your `hosts` file: `127.0.0.1 gh.repro.sp.dev`.\r\n\r\n## e2e tests\r\n\r\nThe e2e tests are located under the `e2e` directory.\r\nThe tests can be run using `npm test`.\r\n\r\n## See the error in action\r\n\r\n- Start the hosting service using `dotnet run` under the `hosting-service` directory.\r\n- Start the tests using `npm test` under the `e2e` directory.\r\n\r\nThere should be intermittent errors:\r\n\r\n```log\r\nfail: Microsoft.AspNetCore.Server.HttpSys.HttpSysListener[6]\r\n      ProcessRequestAsync\r\n      System.ObjectDisposedException: Cannot access a disposed object.\r\n      Object name: 'Microsoft.AspNetCore.Server.HttpSys.ResponseBody'.\r\n         at Microsoft.AspNetCore.Server.HttpSys.ResponseBody.CheckDisposed()\r\n         at Microsoft.AspNetCore.Server.HttpSys.ResponseBody.WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)\r\n         at System.IO.Stream.WriteAsync(ReadOnlyMemory`1 buffer, CancellationToken cancellationToken)\r\n         at Microsoft.AspNetCore.Server.HttpSys.ResponseStream.WriteAsync(ReadOnlyMemory`1 buffer, CancellationToken cancellationToken)\r\n         at System.IO.Pipelines.StreamPipeWriter.FlushAsyncInternal(Boolean writeToStream, ReadOnlyMemory`1 data, CancellationToken cancellationToken)\r\n         at System.IO.Pipelines.StreamPipeWriter.CompleteAsync(Exception exception)\r\n         at Microsoft.AspNetCore.Server.HttpSys.RequestContext.CompleteAsync()\r\n         at Microsoft.AspNetCore.Server.HttpSys.RequestContext`1.ExecuteAsync()\r\n         at Microsoft.AspNetCore.Server.HttpSys.RequestContext`1.ExecuteAsync()\r\n```\r\n\r\n## Important additional information\r\n\r\nThe error occurs when the log level is set to `Information`.\r\nIf the log level is changed to `Trace` (`appsettings.Development.json`), ...\r\n\r\n```diff\r\n {\r\n   \"Logging\": {\r\n \t\"LogLevel\": {\r\n- \t\t\"Default\": \"Information\",\r\n- \t\t\"System\": \"Information\",\r\n- \t\t\"Microsoft\": \"Information\",\r\n- \t\t\"Microsoft.AspNetCore\": \"Information\",\r\n+ \t\t\"Default\": \"Trace\",\r\n+ \t\t\"System\": \"Trace\",\r\n+ \t\t\"Microsoft\": \"Trace\",\r\n+ \t\t\"Microsoft.AspNetCore\": \"Trace\"\r\n \t}\r\n   }\r\n }\r\n\r\n```\r\n\r\n...it seems that the `fail` log is changed into a `dbug` log.\r\n\r\n```log\r\ndbug: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[14]\r\n      The file transmission was cancelled\r\n      System.Threading.Tasks.TaskCanceledException: A task was canceled.\r\n         at Microsoft.AspNetCore.Server.HttpSys.ResponseStream.FlushAsync(CancellationToken cancellationToken)\r\n         at Microsoft.AspNetCore.ResponseCaching.ResponseCachingStream.FlushAsync(CancellationToken cancellationToken)\r\n         at Microsoft.AspNetCore.Http.StreamResponseBodyFeature.SendFileAsync(String path, Int64 offset, Nullable`1 count, CancellationToken cancellationToken)\r\n         at Microsoft.AspNetCore.Http.SendFileResponseExtensions.SendFileAsyncCore(HttpResponse response, String fileName, Int64 offset, Nullable`1 count, CancellationToken cancellationToken)\r\n         at Microsoft.AspNetCore.Http.SendFileResponseExtensions.SendFileAsyncCore(HttpResponse response, IFileInfo file, Int64 offset, Nullable`1 count, CancellationToken cancellationToken)\r\n         at Microsoft.AspNetCore.StaticFiles.StaticFileContext.SendAsync()\r\n```\r\n\r\nAlso note that the problem cannot be reproduced for `http` (as opposed to `https`) hosting.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayan751%2Fnetcore-httpsys-object-disposed-repro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsayan751%2Fnetcore-httpsys-object-disposed-repro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayan751%2Fnetcore-httpsys-object-disposed-repro/lists"}