helix-bridge / relayer

GNU General Public License v3.0
1 stars 1 forks source link

add monitor for relayer #16

Open xiaoch05 opened 5 months ago

xiaoch05 commented 5 months ago
  1. Why does relayer hang due to network issues?
  2. If relayer hangs, kill the process and restart it.
fewensa commented 5 months ago

because some dependencies have internal check and throw exception. the relayer not handle these exceptions. https://github.com/ethers-io/ethers.js/blob/ad5f1c5fc7b73cfb20d9012b669e9dcb9122d244/lib.commonjs/providers/provider-jsonrpc.js#L140-L182

image

You should add this listen to handle these exceptions wait next run.

    process.on('uncaughtException', (error) => {
      console.error(error.message)
      console.log('skip')
    })

but relayer program is use nest.js, maybe schedule exist can not restart again. that why i plan not use nest to develop slasher

fewensa commented 5 months ago

e.g.

public async testError2() {
    new Promise((resolve, reject) => {
      try {
        throw new Error("hello");
      } catch (e: any) {
        reject(new Error("world"));
      }
    });
  }

async main() {
   try {
    await testError2(); // a. will undefined
    while(true) { console.log(1) } // b
    } catch(e) { console.log(e) }
}

e.g.

async function fnb() {
  new Promise((resolve, reject) => {
    reject(new Error('word'));
  });
}

async function fna() {
  return new Promise((resolve, reject) => {
    reject(new Error('Hello'))
  });
}

async function t1() {
  try { await fna() } catch(e) { console.log('---> a', e)}
  console.log('after a')
}

async function t2() {
  try { await fnb() } catch(e) {console.log('---> b', e)}
  console.log('after b');
}

try {
  t2()
    .then(() => console.log('done' ))
    .catch(e => console.log('====>', e));
} catch(x) {
  console.log('-=-=-=>', x);
}