The code for sending requests via WebSockets misses proper error handling, such that problems cannot be handled in user code.
const steem = require("steem");
steem.api.setOptions({ url: "wss://steemd.privex.io" });
steem.api.getAccounts(["nafestw"], (err, resp) => {
console.log("Callback is called. err = " + err);
});
The callback is called with err set to an object describing the error, which should be printed to the console.
The following error occurs and the callback function is not called.
Unhandled rejection Error: getaddrinfo ENOTFOUND steemd.privex.io steemd.privex.io:443
at errnoException (dns.js:55:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:97:26)
Adding the missing .catch in src/api/transports/ws.js should fix the problem:
diff --git a/src/api/transports/ws.js b/src/api/transports/ws.js
index 863ec4f..814d701 100644
--- a/src/api/transports/ws.js
+++ b/src/api/transports/ws.js
@@ -94,7 +94,7 @@ export default class WsTransport extends Transport {
this._requests.set(_request.message.id, _request);
this.ws.send(JSON.stringify(_request.message));
return deferral;
- });
+ }).catch(err => callback(err, null));
}
onError(error) {