catch async error when connecting to network#42
catch async error when connecting to network#42mattcasey wants to merge 2 commits intoLIT-Protocol:mainfrom
Conversation
|
Hi, I saw the original code got updated, but it doesn't look like the correct fix. Catch/throw an error will still result in crashing the process. It also makes it a bit more brittle, since any node connection error will crash the whole thing, whereas before it would resolve so long as a minimum amount of nodes were up. This is a simplified version of the code: In order for the error to not crash the process, you need to
|
|
I agree the problem persists. In case of an error, there is no way for the user to catch it because it is thrown asynchronously de-facto. Perhaps something like below would make the error catchable: async connect() {
// handshake with each node
await Promise.all(this.config.bootstrapUrls.map((url) => {
return this.handshakeWithSgx({ url }).then((resp) => {
this.connectedNodes.add(url);
this.serverKeys[url] = {
serverPubKey: resp.serverPublicKey,
subnetPubKey: resp.subnetPublicKey,
networkPubKey: resp.networkPublicKey,
networkPubKeySet: resp.networkPublicKeySet,
};
})
return new Promise((resolve) => {
// ... and so forth
})
} |
When the Lit Protocol is down, there's no way for the user to catch the exception resulting in an unhandledPromiseRejection. This was crashing our application. Not sure if we would want to add some logging, or maybe add a timeout if the client never returns.