Skip to content

Linux: gnome-keyring timeout can add up to 50 seconds (first time) when trying to persist the MSAL Cache #650

@embetten

Description

@embetten

Summary

If gnome-keyring is in a bad state on Linux, the first invocation in a session can take up to 50 seconds longer than expected. The MSAL token cache tries to use the Linux keyring via libsecret/D-Bus, and if gnome-keyring-daemon can't respond (e.g., the keyring is locked), D-Bus service activation times out before the credential provider falls back to a plaintext cache. I observed subsequent invocations in the same D-Bus session may see a shorter ~6 second delay (cached failure) when the msal cache is initialized.

This applies to credential provider versions 2.0.0+ that integrate with the new MSAL client versions that attempts to use keyring to encrypt the MSAL cache. It was observed intermittently on WSL (Ubuntu) between instance restarts.

WSL Workaround

Restart your WSL instance:

wsl --shutdown

Then reopen WSL. This clears the stale D-Bus state and hopefully allows gnome-keyring to reinitialize cleanly.

Log Excerpt

When this occurs, you'll see a gap of 6–50 seconds between Using MSAL cache at ... and MSAL using Broker in debug logs, along with:

Microsoft.Identity.Client.Extensions.Msal.MsalCachePersistenceException: Persistence check failed.
 ---> Microsoft.Identity.Extensions.InteropException: An error was encountered while saving secret to keyring
   in the Storage domain:'147' code:'24'
   message:'Error calling StartServiceByName for org.freedesktop.secrets: Timeout was reached'

Metadata

Metadata

Assignees

No one assigned

    Labels

    externalSomething is wrong in one of our external dependencies.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions