Handling cancelled request with Express/Node.js and Angular

后端 未结 3 1649
深忆病人
深忆病人 2020-12-25 12:00

When a pending HTTP request is cancelled by a client/browser it seems that Node with Express continues to process the request. For intensive requests, the CPU is still being

3条回答
  •  粉色の甜心
    2020-12-25 12:22

    You can set a timeout for requests on your server:

    var server = app.listen(app.get('port'), function() {
      debug('Express server listening on port ' + server.address().port);
    });
    // Set the timeout for a request to 1sec
    server.timeout = 1000;
    

提交回复
热议问题