Michael
Michael2d ago

Error when unsubscribing from browser.ConvexClient query

The error is: Cannot read properties of undefined (reading 'numSubscribers'), here in convex/browser. We are using the browser.ConvexClient in a Hono app to listen to updates from Convex, as outlined below. While calling unsubscribe too many times, an error is triggered inside the Convex code. How can I test if it's safe to call unsubscribe? Since unsubscribe returns void, I think it would be better if it just doesn't do anything rather than produce an error if I unsubscribe too often.
const unsubscribe = client.onUpdate(api.queries.myquery, { id: myid }, updateHandler, errorHandler);
...
unsubscribe?.()
unsubscribe?.()
const unsubscribe = client.onUpdate(api.queries.myquery, { id: myid }, updateHandler, errorHandler);
...
unsubscribe?.()
unsubscribe?.()
GitHub
convex-js/src/browser/sync/local_state.ts at f7d0bdb241f0b5e911887f...
TypeScript/JavaScript client library for Convex. Contribute to get-convex/convex-js development by creating an account on GitHub.
1 Reply
Convex Bot
Convex Bot2d 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. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!

Did you find this page helpful?