`pubsubSubscribeOnProvider` fails with "Already subscribed" error when publishing comments
When publishing a comment, plebbit-js attempts to subscribe to a pubsub topic but fails with:
Error: Already subscribed to [subplebbit address] with this handler
The comment may still publish successfully, but the error suggests a race condition or duplicate subscription attempt.
Steps to Reproduce
- Run a local plebbit-cli
- Initialize a
Plebbit-JSinstance in a web-app connecting to the local plebbit-cli - Create and publish a comment:
const signer = await this.plebbit.createSigner(); const comment = (await this.plebbit.createComment({ signer, subplebbitAddress: this.subplebbitAddress, title: post.title, content: post.content })) as PublishableComment; - Observe the error in logs.
Expected Behavior
- Expecting a "challenge" event
Actual Behavior
- The error occurs
- Logs show:
plebbit-js:plebbit:client-manager:pubsubSubscribeOnProvider:error Failed to subscribe to pubsub topic [...] Error: Already subscribed to [...]
Environment
-
plebbit-jslatest version of today
Additional Context
- The error occurs during the
waiting-challenge→publishing-challenge-requesttransition. - yesterday I received the challenge succesfully, not sure if I changed code since then
- I updated plebbit-js to latest version as far as I know for the web app and also on plebbit-cli
I assume the error occurs in plebbit-cli logs?
Can you send me your full code, I can't seem to reproduce this
It's interesting: I could resolve the issue by creating anew subplebbit and then posting to it just worked. I am closing the issue because, it's unclear how this can be reproduced. Will open it again if it appears again!
The situation seems more interesting then thought before:
- I create a new subplebbit
- I post and solve the Captcha and everything is normal! (I can post as many posts I want)
- I wait one day and I receive the above error which appears in plebbit-cli logs "already subscribed"
- I need to create a new subplebbit so I can post again. (which is naturally a bit strange)
So the error comes always after a new day. I am creating a new signer for every post at the moment in https://github.com/NiKrause/pleblib-svelte/blob/main/src/lib/stores/publish.ts#L114
This is this code https://github.com/NiKrause/pleblib-svelte/blob/main/src/lib/stores/publish.ts
publishComment: options: {subplebbitAddress: '12D3KooWNF2b1eQiF7y7NqtY9wxJMKs8P9GvrmvvAG93FKPmK2R2', content: 'test', title: 'dienstag'}
publish.ts:91 currentOptions after store update: {subplebbitAddress: '12D3KooWNF2b1eQiF7y7NqtY9wxJMKs8P9GvrmvvAG93FKPmK2R2', title: 'dienstag', content: 'test', parentCid: undefined, signer: undefined}
publish.ts:105 plebbit instance: PlebbitWithRpcClient {parsedPlebbitOptions: {…}, plebbitRpcClientsOptions: Array(1), ipfsGatewayUrls: undefined, kuboRpcClientsOptions: undefined, pubsubKuboRpcClientsOptions: undefined, …}
publish.ts:106 currentOptions before comment creation: {subplebbitAddress: '12D3KooWNF2b1eQiF7y7NqtY9wxJMKs8P9GvrmvvAG93FKPmK2R2', title: 'dienstag', content: 'test', parentCid: undefined, signer: undefined}
publish.ts:109 Available accounts: []
publish.ts:111 Using default account: undefined
publish.ts:123 Comment created successfully: Comment {raw: {…}, publishingState: 'stopped', state: 'stopped', clients: {…}, publish: ƒ, …}
publish.ts:196 Starting comment publication...
publish.ts:162 Publishing state changed: publishing-challenge-request
publish.ts:164 publishing-challenge-request
publish.ts:162 Publishing state changed: waiting-challenge
publish.ts:198 Comment published successfully
publish.ts:162 Publishing state changed: publishing-challenge-request
publish.ts:164 publishing-challenge-request
(if I'd create a new subplebbit right now I'd successfully receive a challenge!
Latest commit, a8754456fd2cd061a2b050d73beee588483d6714 should fix it. Try it and let me know
I updated plebbit-js and tried to post to one of my "hanging" subplebbit test communities. Here unfortunately it was the same situation as before I couldn't add any new post. So I created a new subplebbit and added another new post, as expected succesfull!
Waiting now until tomorrow if this subplebbit is still working! I'll keep you informed then! Around tomorrow same time.
Actually my bad, I forgot to update plebbit-cli to use the latest plebbit-js. If you update to the latest plebbit-cli it should work
I didn't even use a new plebbit-cli with latest plebbit-js :( So that means I need to create a new plebbit-cli and the app with latest plebbit-js! wait a sec - going to try!
I tested it, but so far without success or changes regarding to the old testing results. I have a new Plebbit React Hooks lib now, which is directly ported with Warp. Lets see if that
Make sure plebbit-cli is on v0.16.12, and plebbit-js is on a8754456fd2cd061a2b050d73beee588483d6714.
What do you mean no changes? Is it still giving the Already subscribed to error?
is plebbit-cli working automically with the correct plebbit-js when building? Or I need to update manually?
Are you building plebbit-cli on latest commit? It should pick up the correct plebbit-js then