Custom user data stale in functions?

Good day!

I’ve a very quick question about custom user data. The SDK docs state that changed user data may be stale for up to 30 minutes, e.g. until the next access token refresh.

Is the same true for server-side functions and function rules? Or will changes be reflected immediately in server-side functions?

Thanks in advance!

Hi @Mathias_Gerdt,

Can you please share a direct link to the right paragraph in the doc please? I think I can answer but I’d like to confirm first.


Thanks in advance!

Are you referring to this?

Custom Data May Be Stale
Atlas App Services does not dynamically update a user’s custom data if the underlying document changes. Instead, Atlas App Services fetches a new copy of the data whenever a user refreshes their access token, such as when they log in. This may mean that the custom data won’t immediately reflect changes, e.g. updates from an authentication Trigger. If the token is not refreshed, App Services waits 30 minutes and then refreshes it on the next call to the backend, so custom user data could be stale for up to 30 minutes plus the time until the next SDK call to the backend occurs.

This means that you can only retrieve the user’s custom data when he sends an authentication query which at worst happens every 30 min because the token expires every 30 min.

This is because user’s custom data are stored by the Third Party Auth service (like Google OAuth) and they can be stored in MongoDB only when they are sent to MongoDB during an authentication query.

Server-side functions and rules aren’t impacted by this and will be updated as soon as you push (deploy) a new one to take its place.


So just to clarify:
If I update a user’s custom data, say in the “users” collection, e.g. with a new name, and then run a function some seconds later, will

be the new name with no delay?

I think we are talking about these fields (screenshot from Authentication > Authentication Providers > Google)

I think there won’t be a delay if you update manually but it will be overwritten by the value from Google OAuth when the user authenticates. I would need to test. :cold_sweat:

Ah, I think there is a misunderstanding. :slight_smile:
I didn’t mean data from authentication providers, but manually linked custom user data from my own “users” collection. Will those changes be reflected instantly when using realm functions or server-side rules?
Again, thanks in advance. :slight_smile:

Ha yes, I think this should be reflected immediately. Give it a try and let me know if that’s not the case.