danwrong/restler — Issue #44: No way to cancel a request
Author: hugovincent
Created: 2011-10-23 17:18:16+00:00
State: open

Sometimes you need to cancel a request and guarantees that the request callback does not get executed.

Here is an implementation (note that in Node 0.5 builds, but not 0.4.x, removeAllListeners with no arguments can be used instead of manually manipulating _events), however it is apparently incorrect as I find the callback still gets executed and I need to manually check the .cancelled key in my callback:

restler.Request.prototype.cancel = function() {
if (this.options.originalRequest) {
this.options.originalRequest._events = {};
}
this._events = {};
this.cancelled = true;
return;
};

Does RESTler do some kind of internal queueing or something that is preventing this from working?