Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: this.api.start is not a function when type is 'proc' #466

Closed
bluelovers opened this issue Feb 20, 2020 · 5 comments
Closed

TypeError: this.api.start is not a function when type is 'proc' #466

bluelovers opened this issue Feb 20, 2020 · 5 comments

Comments

@bluelovers
Copy link

bluelovers commented Feb 20, 2020

    "ipfs": "^0.41.1",
    "ipfsd-ctl": "^3.0.0"
(node:87572) UnhandledPromiseRejectionWarning: TypeError: this.api.id is not a function
    at Daemon.start (G:\Users\The Project\p2p\ws-ipfs\node_modules\ipfsd-ctl\src\ipfsd-daemon.js:222:31)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
import { createController } from 'ipfsd-ctl';

(async () => {
	let ipfsd = await createController({
		type: 'proc',
		ipfsModule: require('ipfs'),
		ipfsHttpModule: require('ipfs-http-client'),
		ipfsBin: require.resolve('ipfs/src/cli/bin.js'),
		ipfsOptions: {
			EXPERIMENTAL: {
				pubsub: true,
				ipnsPubsub: true,
				sharding: true,
				dht: true,
			},
			relay: {
				enabled: true,
				hop: {
					enabled: true
				}
			},
		},
		disposable: false,
	});


	await ipfsd.start();
	let ipfs = ipfsd.api;
	console.log(await ipfs.id())
})();
@hugomrdias
Copy link
Member

can you please give more context on this issue, format your code better and review the options you are passing they seems off.

@bluelovers
Copy link
Author

image

image

@achingbrain
Copy link
Member

If you pass disposable: false you need to ensure the node is initialised and started before you use it, so you need to call await ipfsd.init() before calling await ipfsd.start().

https://github.com/ipfs/js-ipfsd-ctl#disposable-vs-non-disposable-nodes

As a separate issue the this.api.start is not a function error will be fixed by ipfs/js-ipfs#2762

@bluelovers
Copy link
Author

image

i add await ipfsd.init()

but still get NotInitializedError: not initialized

@achingbrain
Copy link
Member

It works for me like this, though I think there is an API regression here in that the init/start invocations are inconsistent:

const { createController } = require('ipfsd-ctl');

(async () => {
	let ipfsd = await createController({
		type: 'proc',
		ipfsModule: require('ipfs'),
		ipfsOptions: {
			init: true,
			EXPERIMENTAL: {
				pubsub: true,
				ipnsPubsub: true,
				sharding: true,
				dht: true,
			},
			relay: {
				enabled: true,
				hop: {
					enabled: true
				}
			},
		},
		disposable: false
	});

	await ipfsd.start();
	let ipfs = ipfsd.api;
	console.log(await ipfs.id())
})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants