tomas / needle

Nimble, streamable HTTP client for Node.js. With proxy, iconv, cookie, deflate & multipart support.

Home Page:https://www.npmjs.com/package/needle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

open_timeout seems to be blocking

andrewlight13 opened this issue · comments

I've got a needle request to a service that sometimes takes a long time to respond, occasionally exceeding the open_timeout limit of 10 seconds. However, when it does so, no error is thrown, and the program seems to block on this line:

needle.defaults({
    open_timeout: 10000,
});
let response;
try{
    response = await needle('get', requestUrl, await this.getAuthHeaders());
    console.log("await completed");
}catch(err){
    console.error(err);
}

if open_timeout is triggered, Chrome reports that the connection was cancelled, but neither the console.log statement nor the console.error statement are triggered. Am I missing some other method of handling this timeout, or is this a bug?

I have a similar issue. In some cases a http/https request doesn't response neither with a success nor an error. So it's also blocking the complete script.
The only difference between your code and mine is that i'm using proxy settings.

Did you set response_timeout? Server can accept your request but hold response.