-
Notifications
You must be signed in to change notification settings - Fork 296
Add timeout for the ipfs api calls #781
Comments
@diasdavid hey, what's the |
Thanks for offering to help! The This feature needs https://github.com/ipfs/interface-ipfs-core/issues/58 which is the crux to have timeouts. |
@diasdavid I did some digging at the code, under the hood you're using the So I added the following code after: req.setTimeout(timeout, function() {
console.log('TIMEOUT')
throw new Error('TIMEOUT')
}) It did throw an error, so if I'm not missing something we can start with that as a prototype. |
@diasdavid hey, any comment? If the contributors are ok with that approach I'd like to make a PR |
Are there any updates on this? Such functionality would be super helpful. |
@obo20 Eventually I just implemented it with a You can see it here https://github.com/ColuLocalNetwork/CLN-community-app/blob/master/server/src/utils/metadata.js#L21 |
@leonprou Correct me if I'm wrong, but wouldn't that lead to memory leakage? It's my understanding that when using Promise.race, the promise that is "timed out" still actually executes code. If the promise never returns, then that memory would effectively be locked wouldn't it? From my research it seems like the js-ipfs-http-client doesn't actually have a way of timing out its own requests so theoretically the request could go on indefinitely, which would lead to memory leakage. I'm really hoping that I'm wrong on this, and if anybody has a better understanding of this, I'd love to learn more. For context, I'm using the ipfs.pin.add functionality, so I may never be able to find specific content that I'm requested to find. @daviddias Is there anything under the hood of the js-ipfs-http-client that cleans up requests after a certain amount of time? Or are these types of memory leaks currently possible? I wasn't able to find any timeouts from my searches. I do see timeouts being used in the test suite, so I'm curious how this is all accounted for in the tests? It seems throws are utilized, which wouldn't be great in a production environment. |
Hi, |
Timeouts landed in master today and will be in the next release, see https://github.com/ipfs/js-ipfs-http-client#global-timeouts |
I would like to restrict the api call to a certain timeout, and if response not received to have some TimeoutError. Like an HTTP call. Looking into the docs didn't find that option.
The text was updated successfully, but these errors were encountered: