vrchat-community / creator-companion

The Entry Point for Making Things in VRChat
https://vrchat.com/home/download
63 stars 431 forks source link

[BUG] Frontend crashes unexpectedly #224

Open anatawa12 opened 1 year ago

anatawa12 commented 1 year ago

Describe the bug Frontend crashes unexpectedly.

To Reproduce Steps to reproduce the behavior: Sorry, I don't have exact steps but if I moved pages very quickly, frontend is likely to crash

Expected behavior Do not crash frontend at any time

Logs Errors from developer tool

Failed to load resource: the server responded with a status of 500 (Internal Server Error)
index-faab5d41.js:1077 

       TypeError: Cannot read properties of undefined (reading 'length')
    at index-faab5d41.js:654:1014
    at Object.b5 [as useMemo] (index-faab5d41.js:38:23895)
    at ge.useMemo (index-faab5d41.js:9:6208)
    at PK (index-faab5d41.js:654:978)
    at c0 (index-faab5d41.js:38:19518)
    at am (index-faab5d41.js:40:3139)
    at G5 (index-faab5d41.js:40:44801)
    at H5 (index-faab5d41.js:40:39763)
    at wC (index-faab5d41.js:40:39691)
    at Bd (index-faab5d41.js:40:39545)
    at vm (index-faab5d41.js:40:35913)
    at ty (index-faab5d41.js:40:36716)
    at oi (index-faab5d41.js:38:3274)
    at index-faab5d41.js:40:34246
(anonymous) @ index-faab5d41.js:1077
index-faab5d41.js:38 

       Uncaught TypeError: Cannot read properties of undefined (reading 'length')
    at index-faab5d41.js:654:1014
    at Object.b5 [as useMemo] (index-faab5d41.js:38:23895)
    at ge.useMemo (index-faab5d41.js:9:6208)
    at PK (index-faab5d41.js:654:978)
    at c0 (index-faab5d41.js:38:19518)
    at am (index-faab5d41.js:40:3139)
    at G5 (index-faab5d41.js:40:44801)
    at H5 (index-faab5d41.js:40:39763)
    at wC (index-faab5d41.js:40:39691)
    at Bd (index-faab5d41.js:40:39545)
    at vm (index-faab5d41.js:40:35913)
    at ty (index-faab5d41.js:40:36716)
    at oi (index-faab5d41.js:38:3274)
    at index-faab5d41.js:40:34246

Error log the time crashed

2023-03-31 23:52:00.559 +09:00 [ERR] Could not read repo file C:\Users\anata\AppData\Local\VRChatCreatorCompanion\Repos\556a9f43-b996-4f1d-9e3c-21711335a321.json because The process cannot access the file 'C:\Users\anata\AppData\Local\VRChatCreatorCompanion\Repos\556a9f43-b996-4f1d-9e3c-21711335a321.json' because it is being used by another process.
2023-03-31 23:52:00.669 +09:00 [ERR] Failed to handle HTTP request: The process cannot access the file 'C:\Users\anata\AppData\Local\VRChatCreatorCompanion\Repos\ba28a4c3-fe97-45d3-b0ca-55c24e52ce3b.json' because it is being used by another process.

Desktop (please complete the following information):

Additional context No unity instances are launched. this measn there's no other processes for VPM.

Even if frontend doesn't crashes, The process cannot access the file 'C:\Users\anata\AppData\Local\VRChatCreatorCompanion\Repos\ba28a4c3-fe97-45d3-b0ca-55c24e52ce3b.json' because it is being used by another process. error is very likely to happens.

I have many repositories. The following is settings.json

{
  "pathToUnityExe": "C:\\Program Files\\Unity\\Hub\\Editor\\2019.4.31f1\\Editor\\Unity.exe",
  "pathToUnityHub": "",
  "userProjects": [
    "D:\\UnityProjects\\iwasynctest",
    "D:\\UnityProjects\\3.1.x-bug",
    "D:\\UnityProjects\\New Project test 217",
    "D:\\UnityProjects\\liltoon-vpm-test-migration-Migrated-4",
    "D:\\UnityProjects\\New Project1",
    "D:\\UnityProjects\\vpm upgrade test project",
    "D:\\UnityProjects\\liltoon-vpm-test-migration-Migrated",
    "D:\\UnityProjects\\liltoon-vpm-test-migration",
    "D:\\UnityProjects\\liltoon-vpm-test",
    "D:\\UnityProjects\\New Project",
    "D:\\UnityProjects\\RISV4-conflict-Migrated",
    "D:\\UnityProjects\\RISV4-conflict",
    "C:\\Users\\anata\\MigrateTests\\world-2022.07.26-Migrated",
    "C:\\Users\\anata\\MigrateTests\\world-2022.07.26",
    "C:\\Users\\anata\\UnityProjects\\vpm-freeze",
    "C:\\Users\\anata\\UnityProjects\\vpm-upgrade-problem",
    "C:\\Users\\anata\\UnityProjects\\migrate-test-vcc104-2-Migrated",
    "C:\\Users\\anata\\UnityProjects\\migrate-test-vcc104-2",
    "C:\\Users\\anata\\UnityProjects\\test1",
    "C:\\Users\\anata\\UnityProjects\\vpm-test",
    "C:\\Users\\anata\\UnityProjects\\QuestSleep",
    "C:\\Users\\anata\\UnityProjects\\KeyboardTester",
    "C:\\Users\\anata\\UnityProjects\\avatartestg",
    "C:\\Users\\anata\\UnityProjects\\UdonSharp1_test",
    "C:\\Users\\anata\\UnityProjects\\Anatawa12-Avaters"
  ],
  "unityEditors": [
    "C:\\Program Files\\Unity\\Hub\\Editor\\2019.4.31f1\\Editor\\Unity.exe"
  ],
  "defaultProjectPath": "D:\\UnityProjects",
  "lastUIState": 4,
  "skipUnityAutoFind": false,
  "userPackageFolders": [
    "C:\\Users\\anata\\Downloads\\jp.lilxyzw.liltoon-1.3.7",
    "C:\\Users\\anata\\AppData\\Local\\VCCPackageInstaller\\Radial Inventory System\\V4.4a",
    "C:\\Users\\anata\\AppData\\Local\\VCCPackageInstaller\\Radial Inventory System\\V4.5.1"
  ],
  "windowSize": 3,
  "skipRequirements": false,
  "lastNewsUpdate": "2023-03-09T08:07:43.8674628Z",
  "allowPii": true,
  "projectBackupPath": "C:\\Users\\anata\\AppData\\Local\\VRChatCreatorCompanion\\Project Backups",
  "showPrereleasePackages": false,
  "selectedProviders": 37,
  "lastSelectedProject": "D:\\UnityProjects\\3.1.x-bug",
  "userRepos": [
    {
      "localPath": "C:\\Users\\anata\\AppData\\Local\\VRChatCreatorCompanion\\Repos\\4f2a6fba-46e9-4002-bc29-6cd836d7fbb0.json",
      "url": "https://vpm.nadena.dev/vpm.json",
      "name": "bd_"
    },
    {
      "localPath": "C:\\Users\\anata\\AppData\\Local\\VRChatCreatorCompanion\\Repos\\ba28a4c3-fe97-45d3-b0ca-55c24e52ce3b.json",
      "url": "https://vpm.anatawa12.com/vpm.json",
      "name": "anatawa12"
    },
    {
      "localPath": "C:\\Users\\anata\\AppData\\Local\\VRChatCreatorCompanion\\Repos\\556a9f43-b996-4f1d-9e3c-21711335a321.json",
      "url": "https://lilxyzw.github.io/vpm-repos/vpm.json",
      "name": "lilxyzw"
    },
    {
      "localPath": "C:\\Users\\anata\\AppData\\Local\\VRChatCreatorCompanion\\Repos\\e9766711-7bb7-4b8f-bd00-3f06b8e1186c.json",
      "url": "https://thryrallo.github.io/VRC-Avatar-Performance-Tools/index.json",
      "name": "de.thryrallo.vrc.avatar-performance-tools Releases"
    }
  ]
}
anatawa12 commented 1 year ago

The error message says because it is being used by another process. however, this can be happened if file is opened for write access. The following is test code.

Test 1 - open as write first, then open as read

var path = @"C:\Users\anata\AppData\Local\VRChatCreatorCompanion\Repos\e9766711-7bb7-4b8f-bd00-3f06b8e1186c.json";

using (var stream1 = System.IO.File.OpenWrite(path))
{
    Console.WriteLine("first stream opened.");
    using (var stream2 = System.IO.File.OpenText(path))
    {
        Console.WriteLine("second stream opened.");
    }
    Console.WriteLine("second stream closed.");
}
Console.WriteLine("first stream closed");
PS C:\Users\anata\test> dotnet run
first stream opened.
Unhandled exception. System.IO.IOException: The process cannot access the file 'C:\Users\anata\AppData\Local\VRChatCreatorCompanion\Repos\e9766711-7bb7-4b8f-bd00-3f06b8e1186c.json' because it is being used by another process.
   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
   at System.IO.File.OpenText(String path)
   at Program.<Main>$(String[] args) in C:\Users\anata\test\Program.cs:line 6

Test 2 - Open as read first and then open as write

var path = @"C:\Users\anata\AppData\Local\VRChatCreatorCompanion\Repos\e9766711-7bb7-4b8f-bd00-3f06b8e1186c.json";

using (var stream1 = System.IO.File.OpenRead(path))
{
    Console.WriteLine("first stream opened.");
    using (var stream2 = System.IO.File.OpenWrite(path))
    {
        Console.WriteLine("second stream opened.");
    }
    Console.WriteLine("second stream closed.");
}
Console.WriteLine("first stream closed");
PS C:\Users\anata\test> dotnet run
first stream opened.
Unhandled exception. System.IO.IOException: The process cannot access the file 'C:\Users\anata\AppData\Local\VRChatCreatorCompanion\Repos\e9766711-7bb7-4b8f-bd00-3f06b8e1186c.json' because it is being used by another process.
   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.File.OpenWrite(String path)
   at Program.<Main>$(String[] args) in C:\Users\anata\test\Program.cs:line 6