mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-23 13:45:48 +00:00
make sure that 'before' event emitted from Request only once
This commit is contained in:
@@ -44,13 +44,15 @@ Request.prototype.request = function(servers, callback_) {
|
||||
const callback = typeof servers === 'function' ? servers : callback_;
|
||||
|
||||
this.emit('before');
|
||||
|
||||
const wasRequested = this.requested;
|
||||
this.requested = true;
|
||||
this.callback(callback);
|
||||
|
||||
if (this.requested) {
|
||||
if (wasRequested) {
|
||||
return this;
|
||||
}
|
||||
|
||||
this.requested = true;
|
||||
this.on('error', function() {});
|
||||
this.emit('request', this.remote);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user