flutter_secure_storage icon indicating copy to clipboard operation
flutter_secure_storage copied to clipboard

PathAccessException: The process cannot access the file because it is being used by another process (Windows only) after breaking changes 9.0.0

Open stan-at-work opened this issue 1 year ago • 12 comments

After I updated to version 9.0.0, I randomly got an error saying: 'The process cannot access the file because it is being used by another process.'

This only happened after I upgraded to version 9.0.0.

I investigated the issue and came to the conclusion that it comes down to this.

If a file wants to read the same key at the same time as another file is writing to the same key, then I get this error.

I fixed this by switching back to the previous stable version.

I suggest updating the readme to alert users of this breaking issue.

This error also corrupts the .dat file, so all your secure storage is corrupted and unusable.

The error:

flutter: Failed to decrypt data: Error 0x00000057: Failure on CryptUnprotectData()
Delete corrupt file: c:\users\USER\appdata\roaming\com.example\APPNAME\flutter_secure_storage.dat
flutter: error on refresh token: PathAccessException: Cannot delete file, path = 'c:\users\USER\appdata\roaming\com.example\APPNAME\flutter_secure_storage.dat' (OS Error: The process cannot access the file because it is being used by another process.
flutter: , errno = 32) - stack: #0   _checkForErrorResponse (dart:io/common.dart:55:9)
flutter: #1   _File._delete.<anonymous closure> (dart:io/file_impl.dart:315:7)
flutter: #2   _rootRunUnary (dart:async/zone.dart:1407:47)
flutter: #3   _CustomZone.runUnary (dart:async/zone.dart:1308:19)
flutter: <asynchronous suspension>
flutter: #4   DpapiJsonFileMapStorage.load
flutter_secure_storage_windows_ffi.dart:267
flutter: <asynchronous suspension>
flutter: #5   FlutterSecureStorageWindows.write
flutter_secure_storage_windows_ffi.dart:142
flutter: <asynchronous suspension>
flutter: #6   CoreAuthRepo.toggleLoginEnvironmentInSecureStorage
core_auth_repo.dart:127
flutter: <asynchronous suspension>
flutter: #7   CoreAuthBloc._tryAutoLogin
core_auth_bloc.dart:113
flutter: <asynchronous suspension>
flutter: #8   Bloc.on.<anonymous closure>.handleEvent
bloc.dart:229
flutter: <asynchronous suspension>
flutter:

Greetings. Please fix ;-) 👍

stan-at-work avatar Oct 12 '23 08:10 stan-at-work

Code example: https://github.com/mogol/flutter_secure_storage/issues/603#issuecomment-1769261086

ReinRaus avatar Oct 18 '23 20:10 ReinRaus

@mogol

stan-at-work avatar Oct 31 '23 11:10 stan-at-work

Any updates on this issue @mogol ?

KristijanMitrik avatar May 02 '24 10:05 KristijanMitrik

Any updates on this issue @mogol ?

You can use the previous version.

stan-at-work avatar May 02 '24 15:05 stan-at-work

any update on this issue?

xenSlayer avatar Jun 14 '24 03:06 xenSlayer

@stan-at-work which previous version are you using to avoid this issue?

xenSlayer avatar Jul 04 '24 07:07 xenSlayer

@stan-at-work which previous version are you using to avoid this issue?

I'm using flutter_secure_storage: ^8.1.0

stan-at-work avatar Jul 05 '24 07:07 stan-at-work