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

[wasm] GenerateWasmBootJson - close file handles #85480

Merged
merged 1 commit into from
Apr 27, 2023

Conversation

radical
Copy link
Member

@radical radical commented Apr 27, 2023

Close files opened with File.OpenRead by utilizing the using pattern.

Background

The hypothesis is that the following operations happen in order:

  1. GenerateBlazorBootExtensionJson calls File.Create to create obj/Release/net8.0/blazor.publish.boot-extension.json, and the file handle is closed
  2. GenerateWasmBootJson opens the same file with File.OpenRead but does not close it
  3. GenerateBlazorBootExtensionJson runs again as part of the nested build, but fails because (2) left the file open
The "GenerateBlazorBootExtensionJson" task failed unexpectedly. [/datadisks/disk1/work/B95509FE/w/998E08AE/e/Templates/BaseFolder/AspNet.hhjg2t3oatk0/Client/AspNet.hhjg2t3oatk0.Client.csproj]
System.IO.IOException: The process cannot access the file '/datadisks/disk1/work/B95509FE/w/998E08AE/e/Templates/BaseFolder/AspNet.hhjg2t3oatk0/Client/obj/Release/net8.0/blazor.publish.boot-extension.json' because it is being used by another process. [/datadisks/disk1/work/B95509FE/w/998E08AE/e/Templates/BaseFolder/AspNet.hhjg2t3oatk0/Client/AspNet.hhjg2t3oatk0.Client.csproj]
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Init(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Int64& fileLength, UnixFileMode& filePermissions) [/datadisks/disk1/work/B95509FE/w/998E08AE/e/Templates/BaseFolder/AspNet.hhjg2t3oatk0/Client/AspNet.hhjg2t3oatk0.Client.csproj]
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Func`4 createOpenException) [/datadisks/disk1/work/B95509FE/w/998E08AE/e/Templates/BaseFolder/AspNet.hhjg2t3oatk0/Client/AspNet.hhjg2t3oatk0.Client.csproj]
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode) [/datadisks/disk1/work/B95509FE/w/998E08AE/e/Templates/BaseFolder/AspNet.hhjg2t3oatk0/Client/AspNet.hhjg2t3oatk0.Client.csproj]
   at System.IO.File.Create(String path) [/datadisks/disk1/work/B95509FE/w/998E08AE/e/Templates/BaseFolder/AspNet.hhjg2t3oatk0/Client/AspNet.hhjg2t3oatk0.Client.csproj]
   at Microsoft.NET.Sdk.BlazorWebAssembly.GenerateBlazorBootExtensionJson.Execute() [/datadisks/disk1/work/B95509FE/w/998E08AE/e/Templates/BaseFolder/AspNet.hhjg2t3oatk0/Client/AspNet.hhjg2t3oatk0.Client.csproj]
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/datadisks/disk1/work/B95509FE/w/998E08AE/e/Templates/BaseFolder/AspNet.hhjg2t3oatk0/Client/AspNet.hhjg2t3oatk0.Client.csproj]
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/datadisks/disk1/work/B95509FE/w/998E08AE/e/Templates/BaseFolder/AspNet.hhjg2t3oatk0/Client/AspNet.hhjg2t3oatk0.Client.csproj]

Close files opened with `File.OpenRead` by utilizing the `using`
pattern.
@lewing
Copy link
Member

lewing commented Apr 27, 2023

/backport to release/8.0-preview4

@github-actions
Copy link
Contributor

Started backporting to release/8.0-preview4: https://github.com/dotnet/runtime/actions/runs/4823593952

@lewing
Copy link
Member

lewing commented Apr 27, 2023

Only the osx lanes are still running and they are not impacted by this change

@lewing lewing merged commit 40390e2 into dotnet:main Apr 27, 2023
@radical radical deleted the wasm-sdk-close-file branch May 1, 2023 21:37
@ghost ghost locked as resolved and limited conversation to collaborators Jun 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants