derhuerst / gemini

Gemini protocol server & client for Node.js.
ISC License
49 stars 8 forks source link

Feature Request: Maximum Time For Request #12

Closed bwestergard closed 1 year ago

bwestergard commented 2 years ago

In addition to the current connection timeout option, it would be quite handy to have a global timeout for requests, akin to gemget's --max-time option.

  -t, --max-time uint          Set the downloading time limit, in seconds. Any download that
                               takes longer will cause an Info output and be deleted.
derhuerst commented 2 years ago

There already is a timeout logic, but just until it receives the header:

https://github.com/derhuerst/gemini/blob/f1f6673e6bf6a5443ead336575ddfb989971ea87/client.js#L49-L52

We could

derhuerst commented 2 years ago

Node.js seems to emit this error if the underlying socket of an HTTP request times out:

https://github.com/nodejs/node/blob/e46c680bf2b211bbd52cf959ca17ee98c7f657f5/test/parallel/test-http-client-set-timeout.js#L34-L38

derhuerst commented 1 year ago

I have added opt.headersTimeout & opt.timeout (for the first byte of the body).

A maximum time of the whole request (including the download of the response) seems out of scope of this library because it makes assumptions about the body size and/or connection speed; I think it would fit nicely into gemini-fetch's scope. @RangerMauve what do you think?