# fetch not responding when there is a timeout function in the server

**URL:** <https://forums.fusetools.com/t/fetch-not-responding-when-there-is-a-timeout-function-in-the-server/5040>\
**Category:** Bug Reports\
**Created:** [February 27, 2017, 11:31am UTC](https://forums.fusetools.com/t/fetch-not-responding-when-there-is-a-timeout-function-in-the-server/5040 "2017-02-27T11:31:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zaulin](https://avatars.discourse-cdn.com/v4/letter/z/d26b3c/32.png) [@zaulin](https://forums.fusetools.com/u/zaulin)\
**Post date:** [February 27, 2017, 11:31am UTC](https://forums.fusetools.com/t/fetch-not-responding-when-there-is-a-timeout-function-in-the-server/5040/1 "2017-02-27T11:31:33Z")

</div>

Hi,

i don’t know if that bug is related to:

[https://www.fusetools.com/community/forums/bug\_reports/fetch\_bug\_when\_server\_not\_responding](https://www.fusetools.com/community/forums/bug_reports/fetch_bug_when_server_not_responding)

in my node.js server i have 2 functions:

```
exports.loginUser = function(req, res) {
  //param
  var params = querystring.parse(req.params.params);
  var param_userName = params["userName"];   
  
  console.log("login user..");

  result =
  [{
    "id": 1,
    "username": "myName"
  }]
  JSONresp = { "request": req.url, "result": "OK", "data": result};
  
  res.writeHead(200, {"Content-Type": "application/json"});
  res.write(JSON.stringify(JSONresp));
  res.end(); 
}

```

this one is fetched with no problem BUT if i add a timeout fuse hangs forever waiting the response:

```
exports.loginUser = function(req, res) {
  //param
  var params = querystring.parse(req.params.params);
  var param_userName = params["userName"];   
  
  console.log("login user..");

  setTimeout( function() { 
        result =
        [{
          "id": 1,
          "username": "myName"
        }]
        JSONresp = { "request": req.url, "result": "OK", "data": result};
        
        res.writeHead(200, {"Content-Type": "application/json"});
        res.write(JSON.stringify(JSONresp));
        res.end();    
    }, 1000)
}

```

both work when requested from browser url.

i found that bug when doing some testing on how to handle requests that took a while to process and even i don’t need that timeout function i guess that may help you to know what is going wrong.

---

<div class="post-metadata">

**Author:** ![Anders\_Bondehagen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_bondehagen/32/98_2.png) [@Anders\_Bondehagen](https://forums.fusetools.com/u/Anders_Bondehagen)\
**Post date:** [February 27, 2017, 11:35am UTC](https://forums.fusetools.com/t/fetch-not-responding-when-there-is-a-timeout-function-in-the-server/5040/2 "2017-02-27T11:35:47Z")

</div>

On what platform is this? Is it on desktop preview or on device?

---

<div class="post-metadata">

**Author:** ![zaulin](https://avatars.discourse-cdn.com/v4/letter/z/d26b3c/32.png) [@zaulin](https://forums.fusetools.com/u/zaulin)\
**Post date:** [February 27, 2017, 1:45pm UTC](https://forums.fusetools.com/t/fetch-not-responding-when-there-is-a-timeout-function-in-the-server/5040/3 "2017-02-27T13:45:33Z")

</div>

Hi!

My problem was that i was having those problems just in my mobile (ios) but never in local so trying to know what was happening i did that testing (the one in my previous post) trying to reproduce it i in local (both node server and app (mac))

Anyway: now i am facing that problem in local (i’ll do more testing later (now at work))

---

<div class="post-metadata">

**Author:** ![zaulin](https://avatars.discourse-cdn.com/v4/letter/z/d26b3c/32.png) [@zaulin](https://forums.fusetools.com/u/zaulin)\
**Post date:** [February 27, 2017, 10:46pm UTC](https://forums.fusetools.com/t/fetch-not-responding-when-there-is-a-timeout-function-in-the-server/5040/4 "2017-02-27T22:46:08Z")

</div>

UPDATE:

After a few testing it seems it depends on the timeout value:

the lower the timeout is set in the node.js server the more likely is to work. I guess fuse has some kind of timeout for the fetch promises.

I also noticed that when testing on my device even if the server answered the request fast it could get stuck if my connection was slow.

---

<div class="post-metadata">

**Author:** ![zaulin](https://avatars.discourse-cdn.com/v4/letter/z/d26b3c/32.png) [@zaulin](https://forums.fusetools.com/u/zaulin)\
**Post date:** [February 27, 2017, 11:18pm UTC](https://forums.fusetools.com/t/fetch-not-responding-when-there-is-a-timeout-function-in-the-server/5040/5 "2017-02-27T23:18:15Z")

</div>

UPDATE:

it seems there was something wrong in my code (i was using the loading button example): [https://www.fusetools.com/examples/loading-button](https://www.fusetools.com/examples/loading-button)

but i will try to find out what was wrong in case it was a bug (as even if the code was so so it makes no sense that a fetch request made the app not responding when not answered by the server)

---

<div class="post-metadata">

**Author:** ![Anders\_Bondehagen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_bondehagen/32/98_2.png) [@Anders\_Bondehagen](https://forums.fusetools.com/u/Anders_Bondehagen)\
**Post date:** [February 28, 2017, 10:06am UTC](https://forums.fusetools.com/t/fetch-not-responding-when-there-is-a-timeout-function-in-the-server/5040/6 "2017-02-28T10:06:04Z")

</div>

Interesting, thank you for looking into it.
