Skip to content

Conversation

@ZvonimirBusic
Copy link
Contributor

@ZvonimirBusic ZvonimirBusic commented Nov 14, 2025

What?

Fixes autoRefresh functionality that was causing "Stay logged in" modal to appear instead of automatically refreshing the token.

Why?

Two issues were preventing autoRefresh from working:

  1. autoRefresh was not exposed in the client config, causing it to be undefined in the browser
  2. The Auth provider's reminder timeout callback was capturing a stale autoRefresh value due to closure timing during initial component render

How?

  • Added autoRefresh to client config creation to expose it to the client
  • Used useEffectEvent in Auth provider to ensure the reminder timeout handler always captures the latest autoRefresh value

Fixes

#14613

@ZvonimirBusic ZvonimirBusic changed the title fix(payload): expose autoRefresh in admin client config fix: expose autoRefresh in admin client config Nov 14, 2025
@ZvonimirBusic ZvonimirBusic marked this pull request as draft November 14, 2025 09:18
@ZvonimirBusic ZvonimirBusic marked this pull request as ready for review November 14, 2025 09:18
@PatrikKozak
Copy link
Contributor

Hey @ZvonimirBusic - thanks for opening this PR!

I was able to validate the original issue however with this fix above, although the autoRefresh is properly exposed to the Auth Provider now, I don't believe the original issue is resolved just yet.

From what I'm seeing:

When a user logs in, the config hasn't fully loaded yet so autoRefresh is undefined. There is a setTimeout callback in the Auth Provider that captures this undefined value in its closure, even though autoRefresh becomes true later, the timeout callback still has the old captured value.

Can you possibly confirm this on your end by running one of our test suites i.e test/_community within this branch and using the configuration as described in the original issue.

I think you'll still see the Stay Logged In modal appear for you.

I can go ahead and push an additional fix here to your branch which should resolve the issue. I just want to make sure that on your end you're still seeing the issue even with exposing the autoRefresh value properly to the provider

@PatrikKozak PatrikKozak self-requested a review November 19, 2025 19:16
@PatrikKozak PatrikKozak changed the title fix: expose autoRefresh in admin client config fix: autoRefresh not working due to stale closure and missing client config Nov 19, 2025
@PatrikKozak PatrikKozak changed the title fix: autoRefresh not working due to stale closure and missing client config fix: autoRefresh not working due to stale closure and missing in client config Nov 19, 2025
@PatrikKozak PatrikKozak merged commit 8a3c6dc into payloadcms:main Nov 20, 2025
93 checks passed
@github-actions
Copy link
Contributor

🚀 This is included in version v3.65.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants