You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it would be useful to give the user the API to abort any intercepted request in a matching request handler.
Note that this doesn't conflict nor replace the user-defined AbortController on the request. The user-defined controller is there for the user to abort the request as a part of their app. The proposed feature is for the user to abort the request as a part of the hander.
The controller API would hook into the existing request.signal, or create one, if it's not defined. Internally, we will have the controller.signal.on('abort') listener to know if the user aborted the request in the handler. If they did, we will translate that event to the appropriate mechanism to abort the request:
Browser
Forward the abort event to the existing/added request.signal abort controller to abort the request for free.
Node.js
Listen to the controller.signal.on('abort') and abort the request via appropriate means:
ClientRequest: by calling this.abort() on the ClientRequest instance. I'm not proposing to attach the signal on the request instance to have as little meddling with the user-defined signal as possible. The downside of tapping into this.abort() directly may be that the user-defined signal will never receive that abort event (because there's no event, we are aborting the request on the lower level).
XMLHttpRequest: by calling this.abort() on the XMLHttpRequest instance.
fetch: by forwarding the abort event to the existing/added abort controller on the request instance.
Questions
What is the semantics of aborting the request in a handler? Handlers stand for server-side behavior. Would this translate to the "server is aborting this request"?
The text was updated successfully, but these errors were encountered:
Scope
Adds a new behavior
Compatibility
Feature description
I think it would be useful to give the user the API to abort any intercepted request in a matching request handler.
How would this work?
The
controller
API would hook into the existingrequest.signal
, or create one, if it's not defined. Internally, we will have thecontroller.signal.on('abort')
listener to know if the user aborted the request in the handler. If they did, we will translate that event to the appropriate mechanism to abort the request:Browser
request.signal
abort controller to abort the request for free.Node.js
controller.signal.on('abort')
and abort the request via appropriate means:this.abort()
on the ClientRequest instance. I'm not proposing to attach thesignal
on the request instance to have as little meddling with the user-defined signal as possible. The downside of tapping intothis.abort()
directly may be that the user-defined signal will never receive that abort event (because there's no event, we are aborting the request on the lower level).this.abort()
on the XMLHttpRequest instance.request
instance.Questions
The text was updated successfully, but these errors were encountered: