Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

lift_uriSuffix can get lost during long-running AJAX requests #1327

Merged
merged 1 commit into from

3 participants

@Shadowfiend
Owner

Because lift_uriSuffix is read during doAjaxCycle, a long-running AJAX request that blocks processing of two sequentially queued AJAX calls can result in mangled uriSuffix reads.

The situation is as such:

  • I do an AJAX request with suffix A. It takes 5s.
  • I do an AJAX request with suffix B. lift_uriSuffix is now B.
  • I do an AJAX request with suffix C. lift_uriSuffix is now C.
  • The first request completes, the second is processed. This request now sees suffix C. It is fired off with the wrong suffix.
  • The second request completes, the third is processed. This request now sees no suffix at all. It is fired off with no suffix.

The solution to this is to read the suffix during lift_ajaxHandler where we queue the request up, rather than waiting for other requests to complete.

@Shadowfiend Shadowfiend Move uriSuffix extraction into lift_ajaxHandler.
By having it in doAjaxCycle, there were situations where the uri suffix
could get lost. The most obvious one was when a long-running ajax
request was occurring, and two AJAX requests were queued during that
time frame. This would result in the first request getting the second
request's uriSuffix, and the second request getting no suffix at all.

We now immediately put the uriSuffix into the sending data when
lift_ajaxHandler is called.
c9279a4
@Shadowfiend Shadowfiend was assigned
@fmpwizard
Owner

+1

@dpp dpp merged commit 932d06b into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 24, 2012
  1. @Shadowfiend

    Move uriSuffix extraction into lift_ajaxHandler.

    Shadowfiend authored
    By having it in doAjaxCycle, there were situations where the uri suffix
    could get lost. The most obvious one was when a long-running ajax
    request was occurring, and two AJAX requests were queued during that
    time frame. This would result in the first request getting the second
    request's uriSuffix, and the second request getting no suffix at all.
    
    We now immediately put the uriSuffix into the sending data when
    lift_ajaxHandler is called.
This page is out of date. Refresh to see the latest.
View
11 web/webkit/src/main/scala/net/liftweb/http/js/ScriptRenderer.scala
@@ -47,6 +47,12 @@ object ScriptRenderer {
toSend.onFailure = theFailure;
toSend.responseType = responseType;
+ if (liftAjax.lift_uriSuffix) {
+ theData += '&' + liftAjax.lift_uriSuffix;
+ toSend.theData = theData;
+ liftAjax.lift_uriSuffix = undefined;
+ }
+
liftAjax.lift_ajaxQueue.push(toSend);
liftAjax.lift_ajaxQueueSort();
liftAjax.lift_doCycleQueueCnt++;
@@ -161,11 +167,6 @@ object ScriptRenderer {
liftAjax.lift_actualJSONCall(aboutToSend.theData, successFunc, failureFunc);
} else {
var theData = aboutToSend.theData;
- if (liftAjax.lift_uriSuffix) {
- theData += '&' + liftAjax.lift_uriSuffix;
- aboutToSend.theData = theData;
- liftAjax.lift_uriSuffix = undefined;
- }
liftAjax.lift_actualAjaxCall(theData, successFunc, failureFunc);
}
}
Something went wrong with that request. Please try again.