Browse Source

fix: stop ipfs on errors

develop
Apostolos Fanakis 4 years ago
parent
commit
38edc413c7
Signed by: Apostolof GPG Key ID: 8600B4C4163B3269
  1. 12
      packages/concordia-pinner/src/index.js
  2. 3
      yarn.lock

12
packages/concordia-pinner/src/index.js

@ -10,13 +10,19 @@ import downloadContractArtifacts from './utils/drizzleUtils';
import getIpfsOptions from './options/ipfsOptions';
import { logger } from './utils/logger';
process.on('unhandledRejection', (error) => {
let ipfsSingleton;
process.on('unhandledRejection', async (error) => {
// This happens when attempting to initialize without any available Swarm addresses (e.g. Rendezvous)
if (error.code === 'ERR_NO_VALID_ADDRESSES') {
logger.error(`unhandledRejection: ${error.message}`);
process.exit(1);
}
if (ipfsSingleton) {
await ipfsSingleton.stop();
}
// Don't swallow other errors
logger.error(error);
throw error;
@ -71,6 +77,10 @@ const main = async () => {
getDeployedContract(web3)
.then(({ contract, contractAddress }) => getIpfsOptions()
.then((ipfsOptions) => IPFS.create(ipfsOptions))
.then((ipfs) => {
ipfsSingleton = ipfs;
return ipfs;
})
.then((ipfs) => createOrbitInstance(ipfs, contractAddress))
.then((orbit) => openExistingUsersDatabases(contract, orbit)
.then(() => {

3
yarn.lock

@ -16469,6 +16469,9 @@ snake-case@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/snake-case/-/snake-case-3.0.4.tgz#4f2bbd568e9935abdfd593f34c691dadb49c452c"
integrity sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==
dependencies:
dot-case "^3.0.4"
tslib "^2.0.3"
snapdragon-node@^2.0.1:
version "2.1.1"

Loading…
Cancel
Save