waku-org / js-waku

JavaScript implementation of Waku v2
https://js.waku.org
Apache License 2.0
167 stars 42 forks source link

bug: filter subscription stops without occasional pings #1923

Closed vpavlin closed 5 months ago

vpavlin commented 6 months ago
This is a **support request** ## Problem I created [waku-dispatcher](https://github.com/vpavlin/waku-dispatcher) some time ago to overcome some of the drawbacks of js-waku - mainly the unreliability in peer connections and message delivery. I tried to update to latest version (0.0.23), which solved my issues with `lightpush` (and not being able to publish), but it is somehow breaking `filter` and my example app fails to receive any messages. Let me describe the flow: 1. Dispatcher gets initialized 2. `dispatcher.start()` then subscribes to the configured `contentTopic` 3. Dispatcher sets up an interval where it attempts to check the subscription (unsing `ping`) and it tries to unsubscribe and subscribe again if the ping fails When I publish the message using the example (https://github.com/vpavlin/waku-dispatcher/tree/chore/update-waku/example) it initially gets delivered fine, but over time the delivery (using `filter`) starts failing and then even the re-subscription attempts start to fail. Various errors seen: ![Screenshot from 2024-03-18 12-42-43](https://github.com/waku-org/js-waku/assets/4759808/68077b60-1502-4e56-ad7d-e31b2185581c) ![Screenshot from 2024-03-18 12-42-32](https://github.com/waku-org/js-waku/assets/4759808/954b0649-61b5-47f1-8a30-65813f2d6cdb) ![Screenshot from 2024-03-18 12-12-04](https://github.com/waku-org/js-waku/assets/4759808/824824b9-84f3-43c1-8b6b-f2a6a78c4000) ![image](https://github.com/waku-org/js-waku/assets/4759808/753f001e-f849-4c71-a603-6225c3f313f6) One way to overcome the errors is to clear the `waku:peers` localStorage field - everything works fine for ~5-10 minutes after I clean it, but then the errors come back again. It is highly possible, that my subscription or peers handling is wrong in `waku-dispatcher`, but I cannot find any obvious issue

How to reproduce

git clone https://github.com/vpavlin/waku-dispatcher.git
cd waku-dispatcher
git checkout chore/update-waku
npm install
npm run build
cd example
npm install ../
npm start

Notes

vpavlin commented 6 months ago

I am running https://github.com/waku-org/lab.waku.org/tree/master/examples/light-js with updated waku/sdk for over an hour, so the problem above probably stems from my attempts to overcome the unreliability:D

vpavlin commented 6 months ago

Actually, that failed after some time also. The strange part is that everythign works perfectly for a while when I clean up the waku:peers localstorage cache.

weboko commented 5 months ago

The task is a bit outdated. Current behavior in the latest version(https://github.com/waku-org/lab.waku.org/pull/60) is as follows (according to @vpavlin):

It is consistently repro for me and easily fixable by using periodic pings.

Problem is addressed in https://github.com/waku-org/js-waku/pull/1970

Next steps:

vpavlin commented 5 months ago

Should I test the PR somehow? HAppy to help verifying it fixes the issues