From 44b7b4bfc07a392ae3834d99c9f9c7d88c0dc8dd Mon Sep 17 00:00:00 2001 From: vrana Date: Tue, 14 Feb 2012 15:47:10 -0800 Subject: [PATCH] Send only one request at a time from ShapedRequest Summary: 'this._request' was never set so 'waiting' was always false. Result was that several requests were sent at once which wastes resources and leads to weird bugs when responses don't arrive in sending order. Blame Rev: D258 Test Plan: Write a comment extremely fast, watch for requests sent. Add sleep(5) for some inputs to DifferentialCommentPreviewController, verify correct order. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1612 --- src/__celerity_resource_map__.php | 36 +++++++++---------- .../rsrc/js/application/core/ShapedRequest.js | 10 +++--- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 85784c1c31..ac1aa99985 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -1510,7 +1510,7 @@ celerity_register_resource_map(array( ), 'phabricator-shaped-request' => array( - 'uri' => '/res/dcd87f90/rsrc/js/application/core/ShapedRequest.js', + 'uri' => '/res/59029fa9/rsrc/js/application/core/ShapedRequest.js', 'type' => 'js', 'requires' => array( @@ -1827,7 +1827,7 @@ celerity_register_resource_map(array( 'uri' => '/res/pkg/b164acea/javelin.pkg.js', 'type' => 'js', ), - 'e2820c7b' => + 'ef420ead' => array( 'name' => 'differential.pkg.js', 'symbols' => @@ -1848,7 +1848,7 @@ celerity_register_resource_map(array( 13 => 'javelin-behavior-phabricator-object-selector', 14 => 'differential-inline-comment-editor', ), - 'uri' => '/res/pkg/e2820c7b/differential.pkg.js', + 'uri' => '/res/pkg/ef420ead/differential.pkg.js', 'type' => 'js', ), ), @@ -1866,7 +1866,7 @@ celerity_register_resource_map(array( 'aphront-typeahead-control-css' => '775f5bae', 'differential-changeset-view-css' => '80580cea', 'differential-core-view-css' => '80580cea', - 'differential-inline-comment-editor' => 'e2820c7b', + 'differential-inline-comment-editor' => 'ef420ead', 'differential-local-commits-view-css' => '80580cea', 'differential-revision-add-comment-css' => '80580cea', 'differential-revision-comment-css' => '80580cea', @@ -1877,20 +1877,20 @@ celerity_register_resource_map(array( 'diffusion-commit-view-css' => '03ef179e', 'javelin-behavior' => 'b164acea', 'javelin-behavior-aphront-basic-tokenizer' => '540effd7', - 'javelin-behavior-aphront-drag-and-drop' => 'e2820c7b', - 'javelin-behavior-aphront-drag-and-drop-textarea' => 'e2820c7b', + 'javelin-behavior-aphront-drag-and-drop' => 'ef420ead', + 'javelin-behavior-aphront-drag-and-drop-textarea' => 'ef420ead', 'javelin-behavior-aphront-form-disable-on-submit' => '46547a92', - 'javelin-behavior-differential-accept-with-errors' => 'e2820c7b', - 'javelin-behavior-differential-add-reviewers-and-ccs' => 'e2820c7b', - 'javelin-behavior-differential-comment-jump' => 'e2820c7b', - 'javelin-behavior-differential-diff-radios' => 'e2820c7b', - 'javelin-behavior-differential-edit-inline-comments' => 'e2820c7b', - 'javelin-behavior-differential-feedback-preview' => 'e2820c7b', - 'javelin-behavior-differential-keyboard-navigation' => 'e2820c7b', - 'javelin-behavior-differential-populate' => 'e2820c7b', - 'javelin-behavior-differential-show-more' => 'e2820c7b', + 'javelin-behavior-differential-accept-with-errors' => 'ef420ead', + 'javelin-behavior-differential-add-reviewers-and-ccs' => 'ef420ead', + 'javelin-behavior-differential-comment-jump' => 'ef420ead', + 'javelin-behavior-differential-diff-radios' => 'ef420ead', + 'javelin-behavior-differential-edit-inline-comments' => 'ef420ead', + 'javelin-behavior-differential-feedback-preview' => 'ef420ead', + 'javelin-behavior-differential-keyboard-navigation' => 'ef420ead', + 'javelin-behavior-differential-populate' => 'ef420ead', + 'javelin-behavior-differential-show-more' => 'ef420ead', 'javelin-behavior-phabricator-keyboard-shortcuts' => '46547a92', - 'javelin-behavior-phabricator-object-selector' => 'e2820c7b', + 'javelin-behavior-phabricator-object-selector' => 'ef420ead', 'javelin-behavior-phabricator-watch-anchor' => '46547a92', 'javelin-behavior-refresh-csrf' => '46547a92', 'javelin-behavior-workflow' => '46547a92', @@ -1915,12 +1915,12 @@ celerity_register_resource_map(array( 'phabricator-core-buttons-css' => '775f5bae', 'phabricator-core-css' => '775f5bae', 'phabricator-directory-css' => '775f5bae', - 'phabricator-drag-and-drop-file-upload' => 'e2820c7b', + 'phabricator-drag-and-drop-file-upload' => 'ef420ead', 'phabricator-keyboard-shortcut' => '46547a92', 'phabricator-keyboard-shortcut-manager' => '46547a92', 'phabricator-object-selector-css' => '80580cea', 'phabricator-remarkup-css' => '775f5bae', - 'phabricator-shaped-request' => 'e2820c7b', + 'phabricator-shaped-request' => 'ef420ead', 'phabricator-standard-page-view' => '775f5bae', 'syntax-highlighting-css' => '775f5bae', ), diff --git a/webroot/rsrc/js/application/core/ShapedRequest.js b/webroot/rsrc/js/application/core/ShapedRequest.js index 9d45b654cb..d64b9297d3 100644 --- a/webroot/rsrc/js/application/core/ShapedRequest.js +++ b/webroot/rsrc/js/application/core/ShapedRequest.js @@ -43,7 +43,7 @@ JX.install('PhabricatorShapedRequest', { if (!waiting && !recent && this.shouldSendRequest(this._last, data)) { this._last = data; - var request = new JX.Request(this._uri, JX.bind(this, function(r) { + this._request = new JX.Request(this._uri, JX.bind(this, function(r) { this._callback(r); this._min = new Date().getTime() + this.getRateLimit(); @@ -53,12 +53,12 @@ JX.install('PhabricatorShapedRequest', { this.getRateLimit() ); })); - request.listen('finally', JX.bind(this, function() { + this._request.listen('finally', JX.bind(this, function() { this._request = null; })); - request.setData(data); - request.setTimeout(this.getRequestTimeout()); - request.send(); + this._request.setData(data); + this._request.setTimeout(this.getRequestTimeout()); + this._request.send(); } else { this._defer = setTimeout( JX.bind(this, this.trigger),