Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug introduced in v0.10.3 regarding multiple remote bloodhounds #899

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/bloodhound/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ var Transport = (function() {
var pendingRequestsCount = 0,
pendingRequests = {},
maxPendingRequests = 6,
sharedCache = new LruCache(10),
cancelled = false,
lastUrl;
sharedCache = new LruCache(10);

// constructor
// -----------

function Transport(o) {
o = o || {};

this.cancelled = false;
this.lastUrl = null;

this._send = o.transport ? callbackToDeferred(o.transport) : $.ajax;
this._get = o.rateLimiter ? o.rateLimiter(this._get) : this._get;

Expand Down Expand Up @@ -50,7 +51,7 @@ var Transport = (function() {

// #149: don't make a network request if there has been a cancellation
// or if the url doesn't match the last url Transport#get was invoked with
if (cancelled || url !== lastUrl) { return; }
if (this.cancelled || url !== this.lastUrl) { return; }

// a request is already in progress, piggyback off of it
if (jqXhr = pendingRequests[url]) {
Expand Down Expand Up @@ -100,8 +101,8 @@ var Transport = (function() {
o = {};
}

cancelled = false;
lastUrl = url;
this.cancelled = false;
this.lastUrl = url;

// in-memory cache hit
if (resp = this._cache.get(url)) {
Expand All @@ -118,7 +119,7 @@ var Transport = (function() {
},

cancel: function() {
cancelled = true;
this.cancelled = true;
}
});

Expand Down