cloudflare / node-cloudflare

Node.js API for Client API
https://cloudflare.github.io/node-cloudflare/
Other
335 stars 92 forks source link

Default timeout not functional #60

Closed Cherry closed 7 months ago

Cherry commented 4 years ago

Looking at https://github.com/cloudflare/node-cloudflare/blob/f3a91319706e23047651243892d7284d97b66af2/lib/Client.js#L52 seems to imply the default timeout for this library is 10 seconds.

However, during times of API outages such as https://www.cloudflarestatus.com/incidents/g7nd3k80rxdb, requests seem to just hang forever, and never timeout.

Code to replicate:

const cloudflare = require('cloudflare')({
    "email": "xxx",
    "key": "xxxxx"
});

cloudflare.dns.add('xxxxxx', {
    content: '1.2.3.4',
    name: '_test.xxxx.xx',
    type: 'A',
    proxied: false
}, (err, results) => {
    // this callback never fires with an error or success - the timeout never occurs and it just waits infinitely
    console.log(err, results);
});
terinjokes commented 4 years ago

https://www.npmjs.com/package/got/v/6.7.1#timeout implies it should be handling issues with connect and socket.

terinjokes commented 4 years ago

@Cherry Did you attempt to manually query the API during the outage (eg, with curl)? If so, what behavior did you see? I'm trying to figure out what a test case here might be.

Cherry commented 4 years ago

I did not unfortunately, sorry.

aarbi commented 3 years ago

it would be great if we can allow setting the timeout in the cloudflare constructor, because currently there is no way to set it up. Also, according to this issue in got: https://github.com/sindresorhus/got/issues/215 https://github.com/cloudflare/node-cloudflare/blob/master/lib/Client.js#L53 should fallback to 0and not undefined. (A side note, the retries option has been changed to retry in the newer version of got) Otherwise, the request would hang forever and the cloudflare wouldn't throw/terminate

azev commented 3 years ago

v. 11.8.2 timeout in options not working. takes longer than defined (ms)