flutter_secure_storage icon indicating copy to clipboard operation
flutter_secure_storage copied to clipboard

[Windows] Frequent Corruption of SecureStorage file

Open mlb5000 opened this issue 8 months ago • 3 comments

We have users who are losing access to their secure storage at seemingly random times, and I haven't been able to track down the issues using error logs alone. Sometimes I see errors in the logs, such as this one:

OSError: OS Error: The process cannot access the file because it is being used by another process.
, errno = 32
FileSystemException: PathAccessException: Cannot delete file, path = 'c:\users\user\appdata\roaming\inventory bot co\inventory bot\flutter_secure_storage.dat' (OS Error: The process cannot access the file because it is being used by another process.
, errno = 32)
  #0      _checkForErrorResponse (dart:io/common.dart:56)
  #1      _File._delete.<fn> (dart:io/file_impl.dart:315)
  File "<asynchronous suspension>"
  #3      DpapiJsonFileMapStorage.load (package:flutter_secure_storage_windows/src/flutter_secure_storage_windows_ffi.dart:280)
  File "<asynchronous suspension>"
  #5      FlutterSecureStorageWindows.read (package:flutter_secure_storage_windows/src/flutter_secure_storage_windows_ffi.dart:88)
  File "<asynchronous suspension>"

And the user will report their storage is just fine. Why would it try to delete the file during a load?

And then I'll encounter this sequence of errors:

WindowsException: Error 0x0000000d: Failure on CryptUnprotectData()
  #0      DpapiJsonFileMapStorage.load.<fn> (package:flutter_secure_storage_windows/src/flutter_secure_storage_windows_ffi.dart:241)
  #1      using (package:ffi/src/arena.dart:124)
  #2      DpapiJsonFileMapStorage.load (package:flutter_secure_storage_windows/src/flutter_secure_storage_windows_ffi.dart:216)
  File "<asynchronous suspension>"
  #4      FlutterSecureStorageWindows.read (package:flutter_secure_storage_windows/src/flutter_secure_storage_windows_ffi.dart:88)
  File "<asynchronous suspension>"

which is almost always a "Fatal" indicator. that they will have to completely rebuild their settings.

How can I make this more resilient to this kind of corruption on Windows?

mlb5000 avatar Apr 21 '25 21:04 mlb5000

⚠️ This issue has been marked as stale because it has been open for 60 days with no activity.

If this issue is still relevant, please comment to keep it active. Otherwise, it will be closed in 60 days.

github-actions[bot] avatar Jun 21 '25 02:06 github-actions[bot]

has this been fixed?

Davete0302 avatar Jul 30 '25 01:07 Davete0302

⚠️ This issue has been marked as stale because it has been open for 60 days with no activity.

If this issue is still relevant, please comment to keep it active. Otherwise, it will be closed in 60 days.

github-actions[bot] avatar Nov 29 '25 02:11 github-actions[bot]