convex auth causes browser "leave site?" prompt on every redirect e.g. stripe or auth
I think this is the line responsible preventing unload: https://github.com/get-convex/convex-auth/blob/ae13cf658370cff616bf68a54a5264da13a10672/src/react/client.tsx#L228
3 Replies
Hmm I haven't seen this specifically with Convex Auth. Can you say more about your set up and how to reproduce this? In general, Convex hooks up an
onbeforeunload
listener to pop up this dialog if there are any mutations or actions that are in flight (https://github.com/get-convex/convex-js/blob/4e4e416c981ef8936ebe45bdf727d03984b7d2de/src/browser/sync/client.ts#L249) so the user doesn't end up losing data.
Is it possible that you're kicking off a mutation / action immediately before trying to leave the page? For debugging, I'd try setting unsavedChangesWarning: false
when instantiating your Convex client (only for debugging, because it's fairly easy for end users to experience data loss without it) or set verbose: true
so you can see some logs when mutations / actions get sent.GitHub
convex-js/src/browser/sync/client.ts at 4e4e416c981ef8936ebe45bdf72...
TypeScript/JavaScript client library for Convex. Contribute to get-convex/convex-js development by creating an account on GitHub.
hmm the url comes from convex mutation but I would think as I have the url and it triggers redirect the mutation would be complete š¤ I will give the debug a try thank you
this is what happens when I click the button
and this is the createCheckoutSession action
this also happens when I click on oauth button
it has something to do with middleware route matcher
when I use matcher as only this it causes problem (recommended from nextjs docs)
If I use it like this including convex auth recommended matcher the problem goes away
š¤
gotta have it matching inclusive of
Could you try updating Convex Auth (0.0.64)? One thing I noticed was that we wouldn't clear the
beforeunload
listeners if we hit an error when trying to fetch a new access token, which would result in that dialog always popping up.