Skip to content
This repository was archived by the owner on Dec 4, 2018. It is now read-only.

FIX: Make node-bitcoin compatable with browserify #22

Closed
wants to merge 1 commit into from
Closed
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
22 changes: 13 additions & 9 deletions lib/jsonrpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,19 @@ Client.prototype.call = function(method, params, callback, errback, path) {
errback(err);
}, this.opts.timeout || 30000);

// set additional timeout on socket in case of remote freeze after sending headers
request.setTimeout(this.opts.timeout || 30000, function() {
if (cbCalled) return;
cbCalled = true;
request.abort();
var err = new Error('ESOCKETTIMEDOUT')
err.code = 'ESOCKETTIMEDOUT'
errback(err);
});
// set additional timeout on socket in case of remote freeze after sending
// header. NOTE: this method does not exist currently inside browserify
// http, which causes a crash
if (request.setTimeout) {
request.setTimeout(this.opts.timeout || 30000, function() {
if (cbCalled) return;
cbCalled = true;
request.abort();
var err = new Error('ESOCKETTIMEDOUT')
err.code = 'ESOCKETTIMEDOUT'
errback(err);
});
}

request.on('error', function(err) {
if (cbCalled) return;
Expand Down