Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

No timeout on ipfs.ls is called #71

Closed
mhhf opened this issue Oct 5, 2015 · 7 comments
Closed

No timeout on ipfs.ls is called #71

mhhf opened this issue Oct 5, 2015 · 7 comments

Comments

@mhhf
Copy link

mhhf commented Oct 5, 2015

Is there a reason why no timeout implemented on the http.request? My problem is: If I request an unavailable hash, the request and its socket stays open forever, which causes problems.

Tested on DigitalOcean Ubuntu 14.04 and OS X 10.10 With node 4.0.0 and ipfs version 0.3.8-dev.
In the following code the callback is never called:

var ipfsApi = require('ipfs-api');

var ipfs = ipfsApi('localhost','5001');

var start = (new Date());
console.log( 'started on ' + start );

ipfs.ls("QmPzWqn4ZRhGFJCTnNvaz3Wwe6inKQ4n6nJic4bAw3maz3", function( err, res ) {
  console.log('got error after '+((new Date() - start)), err );
});
@jbenet
Copy link
Contributor

jbenet commented Oct 9, 2015

Our general view with timeouts is that they're extremely hard to choose
right.

This is actually a very serious problem in the developing world. Many web
servers have HTTP timeouts that are fine for the developed world clients,
but brutal against developing world / rural web clients. High latencies
make many websites entirely unaccessible.

in general, instead of prescribing what timeouts "make sense", we try to
leave timeouts to the callers. However i do agree some default timeout
(that can be turned off) makes sense for the sake of not leaving things
open and hanging. We should:

  • allow the user to specify timeouts
  • have a default (huge) timeout OR require the timeout param

a huge timeout value could be like 30min. (but note even that is not right
in terms of using an ipfs node programmatically. sometimes you want to wait
for the content to be available even if that means waiting hours...

On Monday, October 5, 2015, Denis Erfurt [email protected] wrote:

Is there a reason why no timeout implemented on the http.request? My
problem is: If I request an unavailable hash, the request and its socket
stays open forever, which causes problems.

Tested on DigitalOcean Ubuntu 14.04 and OS X 10.10 With node 4.0.0 and
ipfs version 0.3.8-dev.
In the following code the callback is never called:

var ipfsApi = require('ipfs-api');

var ipfs = ipfsApi('localhost','5001');

var start = (new Date());
console.log( 'started on ' + start );
ipfs.ls("QmPzWqn4ZRhGFJCTnNvaz3Wwe6inKQ4n6nJic4bAw3maz3", function( err, res ) {
console.log('got error after '+((new Date() - start)), err );
});


Reply to this email directly or view it on GitHub
#71.

@victorb
Copy link
Contributor

victorb commented Oct 19, 2015

I would like to suggest doing something like this:

var ipfsApi = require('ipfs-api');

var ipfs = ipfsApi({
    host: 'localhost',
    port: '5001',
    timeout: 10 // ten seconds, default to null = requests never time out, like now
});

var start = (new Date());
console.log( 'started on ' + start );

ipfs.ls("QmPzWqn4ZRhGFJCTnNvaz3Wwe6inKQ4n6nJic4bAw3maz3", function( err, res ) {
  console.log('got error after '+((new Date() - start)), err );
});

Two changes required for this to happen:

  • IPFS params is turned into object instead of normal parameters (for convenience)
  • Adding of the timeout param

@jbenet
Copy link
Contributor

jbenet commented Oct 19, 2015

maybe call it defaultTimeout or globalTimeout or something. timeout makes me think it's a timeout just for the ipfsApi function.

@daviddias
Copy link
Contributor

maybe have defaultTimeout to set for every function and then a timeout for each of the calls?

@daviddias
Copy link
Contributor

How does everyone feel about this issue? Something to be added meanwhile?

@daviddias
Copy link
Contributor

daviddias commented Aug 16, 2016

There is more to this discussion, follow here -> https://github.com/ipfs/interface-ipfs-core/issues/58

@dignifiedquire
Copy link
Contributor

@diasdavid I suggest moving this to milestone 4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants