FAILED_TO_GET_SESSION in user signout (latest version)
Hi there,
I am using:
"better-auth": "^1.3.24",
"next": "15.2.4",
"@daveyplate/better-auth-ui": "^3.2.5",
Everything works fine when during signin and during the user session, but when the user signs out (even manually, just after signing in), the following error arises:
`
I have read the posts related to this error, and the suggestion is to upgrade packages, but I am already in the latest version.
Could you, please, point me to the right direction to debug this?
Thank you!
13 Replies
My config:
Thank you! 🙏🏻
In case it helps, when the I signout (that is when the error happens), these are the request that I can see in my network tab:

the UI shows (it changes between this error and the above mentioned one):

the first request (a react server component payload...??) looks like this:

then...




Even if I do this:
`
(waiting 5 seconds)
I get the same error:

fixed !
tomorrow afternoon I will write a brief explanation, but it was related to a third part widget using a shadowRoot
There it goes:
- In my app, I am using a chat widget comming from a third party saas.
- That chat widget, requires:
1. to add a "div" to my app, where I am expected to set the style of the widget, via css custom properties
2. To run a script to load the widget
- But (and here comes the catch) that script also "imperatively" changed that dive for a custom html element
- Because this last step was done "outside react", react was not aware that the div that I added was no longer there.
- When the component unmounts (on user log out, since the chat was in the auth layout only), React tries to unmount that - now non existent - div
- It cannot find it, which causes the "removeChild" error.
- That somehow ended up affecting and triggering other errors, which were not the root cause.
Fix:
1. Either keep the chat component and never unmount it (for ex, putting it in the app layout), though this is not what I wanted
2. ...or adding the div also "outside of the react flow", imperatively in a useEffect.
I did #2 and it's working fine again 🙂