Non-disposable node not working if repo exists
denyncrawford opened this issue · 4 comments
I'm having some troubles with my electron app, I need to create a non-disposable node, and when I set this option to false, it never connects to the api unless I delete the .ipfs repo that is in my profile or home directory.
When i delete the repo, my app works and it connects but if i restart the app it never does and shows this error:
This is my controller:
export const getDataNode = async () => {
const ipfsd = await createController({
ipfsHttpModule,
ipfsBin,
remote: false,
type: 'js',
ipfsOptions: {
init: true,
start: true,
config: {
API: {
HTTPHeaders: {
"Access-Control-Allow-Origin": [
"*"
],
"Access-Control-Allow-Methods": ["PUT", "POST", "GET", "DELETE"],
"Access-Control-Allow-Credentials": true,
}
},
Addresses: {
Swarm: [
"/ip4/0.0.0.0/tcp/4002",
"/ip4/127.0.0.1/tcp/4003/ws"
],
Gateway: "/ip4/127.0.0.1/tcp/8080",
API: "/ip4/127.0.0.1/tcp/5001"
}
}
},
disposable: false
})
await ipfsd.init();
await ipfsd.start();
return ipfsd.api
}
Do i need to set some options to the start method or something like that?
@denyncrawford check if any of the below helps:
- ipfs-desktop does very similar thing, take a look at https://github.com/ipfs/ipfs-desktop/blob/4b989b135901f585c752e93c0d706bd2df20e72b/src/daemon/daemon.js#L42-L51
- you can see we define
repo:
location which you seem to be missing - I also noticed you have
init: true
and then you init it again manually via an explicitawait ipfsd.init()
- sidenote: As we want to access it from browser-sandboxed window, we tweak Origin header to avoid CORS issues:
https://github.com/ipfs/ipfs-desktop/blob/v0.16.3/src/webui/index.js#L148-L166
(this way we don't need to setAccess-Control-Allow-Origin: *
)
- you can see we define
@lidel Nope, even defining the repo and removing init and start from the ipfsOptions it still doesn't work if my app crash or it is closed incorrectly. I'm running the controller on render process with node integration and running it on main process doesn't work either.
This is my code right now.
The first time it works but if i force a crash on my app it doesn't remove the repo.lock
folder (doesn't work if i remove it, i have to remove all the repo directory to make it work again) and it won't start.
@denyncrawford I see you are calling ipfsd.api.stop()
instead of ipfsd.stop()
– you should use the latter (to make sure shutdown is handled by js-ipfsd-ctl).
Historically there were Electron bugs where before-quit
event was not called correctly (example: electron/electron#9613) – unlikely, but those things happen.
I'm closing this, as there is no reproduction steps.
In the future please provide source code with MVP app that reproduces the error.
For things that are not bugs, but developer/user support, please use https://discuss.ipfs.io/c/help/13, which has more people looking, so higher chance of getting help in timely manner 👍