JS IPFS PubSub Working within a tab, only

Hi, I try to publish messages over PubSub using JS IPFS, but they only seem to be sent within a single browser tab.

Reproduce:

  1. go to js.ipfs.io
  2. Enter
    const node = await IPFS.create();
    node.pubsub.subscribe("test", (message) => {
    console.log(message.data);
    });
    into the first code field and hit “Run”.
  3. Enter
    const node = await IPFS.create();
    node.pubsub.publish("test", "hi");
    into the second code field and hit “Run”.

It will work within one tab, but if you subscribe in one tab and publish in another, the first tab won’t receive anything.

What am I doing wrong? Tried it in Firefox 86 and Brave.

I just now looked at ‘js.ipfs.io’ ! Really cool! I’m pretty sure they’re probably just instantiating some kind of sandbox for people to test in, and even a separate tab will instantiate it’s own separate sandbox, so that’s probably why you can’t do it across multiple tabs. That site is just for demo purposes maybe?