Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not log errors after closing the connection. #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ class ElectrumClient extends Client {
this.timeout = setTimeout(() => {
if (this.timeLastCall !== 0 && new Date().getTime() > this.timeLastCall + 5000) {
const pingTimer = setTimeout(() => {
this.onError(new Error('keepalive ping timeout'));
if (this.timeout != null) {
this.onError(new Error('keepalive ping timeout'));
}
}, 9000);
this.server_ping().catch((reason) => {
console.log('keepalive ping failed because of', reason);
Expand All @@ -75,6 +77,7 @@ class ElectrumClient extends Client {
super.close();
if (this.timeout != null) {
clearTimeout(this.timeout);
this.timeout = null;
}
this.reconnect = this.reconnect = this.onClose = this.keepAlive = () => {}; // dirty hack to make it stop reconnecting
}
Expand Down