Description:
In a pure browser environment, initializing IPFS nodes based on Helia with even an empty services configuration (e.g., libp2p: { services: {} }) disrupts the node's ability to discover peer nodes automatically. However, removing the services option entirely restores peer discovery capabilities. Given the dependencies of OrbitDB on specific libp2p configurations involving the services option (specifically pubsub with gossipsub), it is crucial to enable services.
Steps to Reproduce:
Initialize a Helia-based IPFS node in a clean browser environment with the following configuration:
// index.js
import { IDBBlockstore } from 'blockstore-idb';
import { IDBDatastore } from 'datastore-idb';
import { createHelia } from 'helia';
4. Observe that the node can now discover peers.
**Expected Behavior:**
The node should be able to discover peers automatically, even when the `services` option is used, provided it is configured correctly or even if it is empty.
**Actual Behavior:**
The node fails to discover peers when the `services` option is included in the configuration. Removing this option restores peer discovery functionality.
**Environment:**
- **Browser Version:** Google Chrome 123.0.6312, Microsoft Edge 123.2420
- **Operating System:** Windows 2022
- **Helia Version:** 4.2.1
- **Libp2p Version:** 1.3.3
**Additional Information:**
Despite reviewing the documentation on service-related configurations ([libp2p interface documentation](https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.Libp2p.html#services) and [source code](https://github.com/libp2p/js-libp2p/blob/6efabd689edfec89e69272239dc917edc25a0b94/packages/interface/src/index.ts#L294)), I am still unsure how to resolve this issue.
**Use the Service option to start Helia:**
![image](https://github.com/ipfs/helia/assets/19142891/a3f1a3c3-e08e-4517-83fc-2ad0dd17a431)
**Start Helia without using the Service option:**
![image](https://github.com/ipfs/helia/assets/19142891/a0d57881-329f-4c57-b6bf-3f4a84c69407)
Description:
In a pure browser environment, initializing IPFS nodes based on Helia with even an empty
services
configuration (e.g.,libp2p: { services: {} }
) disrupts the node's ability to discover peer nodes automatically. However, removing theservices
option entirely restores peer discovery capabilities. Given the dependencies of OrbitDB on specificlibp2p
configurations involving theservices
option (specificallypubsub
withgossipsub
), it is crucial to enableservices
.Steps to Reproduce:
const instantiateHeliaNode = async () => { const datastore = new IDBDatastore('/datastore2'); const blockstore = new IDBBlockstore('/blockstore2'); await datastore.open(); await blockstore.open(); const heliaInstance = await createHelia({ libp2p: { services: {} }, peerStore: { persistence: false, threshold: 5 }, keychain: { pass: 'very-strong-password' }, datastore: datastore, blockstore: blockstore });
return heliaInstance; };
document.addEventListener("DOMContentLoaded", async () => { const helia = window.helia = await instantiateHeliaNode();
// monitor console.log('Helia node created with ID:', helia.libp2p.peerId.toString()) setInterval(async () => { const peers = await helia.libp2p.peerStore.all(); console.log(
Total number of store peers: ${peers.length}
); console.log('Connected peers count:', helia.libp2p.getPeers().length); }, 3000); });Remove or delete the
services
configuration and reinitialize the node in a clean browser environment (e.g., a new incognito window):