Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

pubsub err #1546

Closed
mccoysc opened this issue Sep 6, 2018 · 4 comments
Closed

pubsub err #1546

mccoysc opened this issue Sep 6, 2018 · 4 comments

Comments

@mccoysc
Copy link

mccoysc commented Sep 6, 2018

    throw err
    ^

Error: Cannot read property 'subscribe' of undefined
at parseError (C:\Users\mccoyzhou\AppData\Roaming\npm\node_modules\ipfs\node_modules\ipfs-api\src\utils\send-request.js:17:17)
at ClientRequest. (C:\Users\mccoyzhou\AppData\Roaming\npm\node_modules\ipfs\node_modules\ipfs-api\src\utils\send-request.js:47:14)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at HTTPParser.parserOnIncomingClient (_http_client.js:551:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:115:23)
at Socket.socketOnData (_http_client.js:440:20)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)

@alanshaw
Copy link
Member

Hi @mccoysc can you provide some more information? Do you have a code example you can paste here?

@alanshaw alanshaw added the status/ready Ready to be worked label Sep 10, 2018
@tchardin
Copy link

I think this might be the same issue:
(running with the default create-react-app setup and js-ipfs@0.32.0-rc.1)

import React from 'react';
import IPFS from 'ipfs';

class ErrorCases extends React.Component {
  constructor() {
    super();
    this.node = new IPFS({
      repo: String(Math.random() + Date.now()),
      Experimental: {
        pubsub: true,
      },
      config: {
        Addresses: {
          Swarm: [
            '/dns4/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star',
          ],
        },
      },
    });
  }
  componentDidMount() {
    this.node.once('ready', () => {
      this.node.pubsub.subscribe('topic', console.log).catch(console.error);
    });
  }
  render() {
    return null;
  }
}

Error:
screen shot 2018-09-11 at 9 58 03 pm

@tchardin
Copy link

Fixed this btw. Experimental should be EXPERIMENTAL. Rookie mistake!

@alanshaw
Copy link
Member

Yes, the pubsub property doesn't get set on the libp2p node if you don't enable pubsub in the config.

@mccoysc this is likely the cause of your problem too.

@ghost ghost removed the status/ready Ready to be worked label Sep 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants