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

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

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.

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

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))

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.

UPDATE:

it seems there was something wrong in my code (i was using the loading button example): 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)

Interesting, thank you for looking into it.