plebbit-js icon indicating copy to clipboard operation
plebbit-js copied to clipboard

`pubsubSubscribeOnProvider` fails with "Already subscribed" error when publishing comments

Open NiKrause opened this issue 8 months ago • 11 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

  1. Run a local plebbit-cli
  2. Initialize a Plebbit-JS instance in a web-app connecting to the local plebbit-cli
  3. 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;
    
  4. 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-js latest version of today

Additional Context

  • The error occurs during the waiting-challengepublishing-challenge-request transition.
  • 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

NiKrause avatar Jun 04 '25 16:06 NiKrause

I assume the error occurs in plebbit-cli logs?

Can you send me your full code, I can't seem to reproduce this

Rinse12 avatar Jun 06 '25 04:06 Rinse12

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!

NiKrause avatar Jun 11 '25 19:06 NiKrause

The situation seems more interesting then thought before:

  1. I create a new subplebbit
  2. I post and solve the Captcha and everything is normal! (I can post as many posts I want)
  3. I wait one day and I receive the above error which appears in plebbit-cli logs "already subscribed"
  4. 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!

NiKrause avatar Jun 17 '25 13:06 NiKrause

Latest commit, a8754456fd2cd061a2b050d73beee588483d6714 should fix it. Try it and let me know

Rinse12 avatar Jun 22 '25 06:06 Rinse12

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.

NiKrause avatar Jun 22 '25 16:06 NiKrause

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

Rinse12 avatar Jun 23 '25 03:06 Rinse12

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!

NiKrause avatar Jun 23 '25 18:06 NiKrause

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

NiKrause avatar Jun 24 '25 09:06 NiKrause

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?

Rinse12 avatar Jun 26 '25 01:06 Rinse12

is plebbit-cli working automically with the correct plebbit-js when building? Or I need to update manually?

NiKrause avatar Jul 01 '25 06:07 NiKrause

Are you building plebbit-cli on latest commit? It should pick up the correct plebbit-js then

Rinse12 avatar Jul 01 '25 09:07 Rinse12