Skip to content

refactor: handle multiple VS Code windows manipulating the same Secret

Tomas Vik requested to merge 561-handle-async-credentials-change into main

This MR is trying to minimize the chance that two VS Code windows manipulate the same secret in the OS keychain at the same time.

The solution can't be fully atomic without us introducing some lock files on the filesystem. But I think that this MR implementation almost completely reduces a chance of a conflict. And if the conflict happens, the user will see an error message but the data won't get overridden.

graph TD
A[VS Code Window 1] --"secrets.get()"--> B(OS Keychain)
C[VS Code Window 2] --"secrets.store()"--> B

The official VS Code authentication extensions don't handle this scenario at all. But to be fair, they don't handle token refreshing, so there si much fewer writes into the OS Keychain (only when an account is added or removed).

Related to #561 (closed)

Edited by Tomas Vik

Merge request reports