__cokop
__cokop4mo ago

Convex socket connection is disconnected after authentication failure

As shown in the image, when attempting to log in with an expired token, the connection is disconnected after the failure message is returned. Is this the intended behavior? AuthCallback is not being called.
No description
No description
No description
9 Replies
Convex Bot
Convex Bot4mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Ask in the <#1228095053885476985> channel to get a response from <@1072591948499664996>. - Avoid tagging staff unless specifically instructed. Thank you!
sshader
sshader4mo ago
I'm not sure exactly what you're trying to do here, but I'll explain how setAuth on the ConvexReactClient / ConvexClient works. setAuth triggers sending an Authenticate message with the token generated by fetchToken over the websocket. If the token is invalid for any reason, the websocket is disconnected, the client tries to re-authenticate, and starts a new websocket connection with the new (hopefully valid) auth. Adding { verbose: true } as the second argument when initializing your Convex client will generate logs in the console that can show more of what's happening here.
__cokop
__cokopOP4mo ago
I have set up the client using verbose, but when the WebSocket connection is lost, nothing is output to the logs. Additionally, fetchToken and AuthCallback, which should be executed when authentication fails, are not being executed either. It doesn't seem to be attempting to reconnect to the socket.
No description
No description
No description
No description
ballingt
ballingt4mo ago
Could you try disabling the MetaMask extension? There are reports of it removing prototype methods from JavaScript builtins that could be causing an issue here @__cokop
ballingt
ballingt4mo ago
I've not seen this myself, just guessing after reading https://stackoverflow.com/a/76473209/398212
Stack Overflow
What is causing the warning 'Removing intrinsics.%ArrayPrototype%.t...
I am getting following warning on first load of my App. lockdown-install.js:1 Removing intrinsics.%ArrayPrototype%.toReversed intrinsics.%ArrayPrototype%.@@unscopables.toSpliced intrinsics.%
__cokop
__cokopOP4mo ago
I just removed MetaMask and tried again, but the issue remains unresolved. However, the logs are now being output.
No description
sshader
sshader4mo ago
Can you share more context about what you're doing here? Looks like you're trying to set up some sort of custom auth, and have it go through Convex, but without using the Convex Auth (https://labs.convex.dev/auth) library? Is this for a non-React integration with the server portion of Convex Auth? I'm not totally sure what $client is in your code snippets, but if that's a ConvexClient, that seems problematic since that request would usually go over the WS, which would be closed on invalid auth, while fetchAccessToken gets called again
Convex Auth - Convex Auth
Authentication library for your Convex backend
__cokop
__cokopOP4mo ago
I'm using SvelteKit and the convex-svelte library. The $client is a global svelte store that we use across multiple components.
No description
No description
__cokop
__cokopOP4mo ago
As there doesn't seem to be a Convex auth library for SvelteKit, I implemented a simple login and logout functionality myself, along with the ability to fetch user information. This worked well. However, after the token expired, an error occurred indicating that the token had expired, and the socket connection was disconnected. This is fine so far. The problem is that the AuthCallback is not being called, and it's not attempting to reconnect the socket.
No description
No description

Did you find this page helpful?