-
Hello, all. Here is the code I use : this.provider = new Ethers.providers.WebSocketProvider(rpc);
try {
this.provider.on('pending', (txHash) => {
performActions(txHash);
});
} catch (e) {
performActionsFallback();
} But when an error occured when subscribing to So, someone know how can I handle this error to avoid that my app crashes ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Beta Was this translation helpful? Give feedback.
-
@ricmoo Idk if I can move this to issue or not. After furthermore research, I came to the following conclusions:
If you want to fix that in your local npm packages, you need to change: To: }).catch(e => _this.emit("subscribeError", e)); This allows you to catch error in the following way : this.provider = new Ethers.providers.WebSocketProvider(rpc);
this.provider
.on('pending', (txHash) => {
performActions(txHash);
})
.on('subscribeError', e => {
performFallbackActions();
}); |
Beta Was this translation helpful? Give feedback.
@ricmoo Idk if I can move this to issue or not.
After furthermore research, I came to the following conclusions:
If you want to fix that in your local npm packages, you need to change:
ethers.js/packages/providers/lib.esm/websocket-provider.js
Line 181 in bf0b468
To:
This allows you to catch error in the following way :