waku-org / js-waku

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

bug: `TypeError: Cannot use 'in' operator to search for 'contentTopics' in undefined` when creating subscription #2022

Closed dmotz closed 3 months ago

dmotz commented 4 months ago

This is a bug report

Problem

The current docs indicate this way of subscribing to a topic:

const subscription = await node.filter.createSubscription()
await subscription.subscribe([decoder], callback)

However with the current version of the lib, the internal function shardInfoToPubsubTopics() throws:

TypeError: Cannot use 'in' operator to search for 'contentTopics' in undefined as its argument shardInfo is undefined.

This code worked in previous versions.

I see there is a pubsubTopics field when creating the node but the use case here is dynamic topics not known at the time of constructing the node.

weboko commented 3 months ago

Hi @dmotz. That's a good point and we need to update docs to facilitate the change we released couple of weeks ago.

Here is PR with updated docs https://github.com/waku-org/docs.waku.org/pull/199