nomad-xyz/monorepo

NomadContext throws unhandledRejection in case of bad rpc endpoint.

Closed this issue · 1 comments

Package

sdk-bridge

At a high level, what are you trying to do?

Integration nomad-sdk in the connext agents

Describe the bug

NomadContext:checkHomes throws unhandledRejection which will make the whole app crash if we don't have a specific handler like process.on("unhandledRejection").

The reason is that async-await is being used in forEach. In general, the one of them throws an error in forEach, the error won't be caught because forEach doesn't wait for each promise to resolve, this basically works in parallel, not serial.

async checkHomes(networks: (string | number)[]): Promise<void> {
    networks.forEach(async (n) => await this.checkHome(n));
}

This seems to be updated properly

#393
done in this pr. nice work! @ErinHales