ipfs/js-ipfsd-ctl

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:

image

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?

@lidel will point to example that works with ipfs-desktop.

lidel commented

@denyncrawford check if any of the below helps:

@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.
code
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.

lidel commented

@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 👍