Handling cancelled request with Express/Node.js and Angular

后端 未结 3 1660
深忆病人
深忆病人 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

    With express, you can try:

    req.connection.on('close',function(){    
      // code to handle connection abort
      console.log('user cancelled');
    });
    

提交回复
热议问题