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 kept busy with unnecessary requests.
Is there a way to ask Node.js/Express to kill/stop these pending requests that are requested to be cancelled?
It becomes particularly useful given that since AngularJS 1.5 HTTP request are easily cancellable by calling $cancelRequest()
on $http
/$resource
objects.
Such cancellations could occur when exposing an API method providing results for auto-completion or search fields: when typing in the field to be autocompleted or type-aheaded, previous request(s) can be cancelled.
A global server.timeout
does not solve the problem: 1) it is a priori a global setting for all exposed API methods 2) ongoing processing in the canceled request is not killed.
"aborted"
instead of"close"
. nodejs.org/api/http.html#http_event_aborted – Airedale