1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-14 08:41:07 +01:00

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
This commit is contained in:
vrana 2012-02-14 15:47:10 -08:00
parent ba05ac595c
commit 44b7b4bfc0
2 changed files with 23 additions and 23 deletions

View file

@ -1510,7 +1510,7 @@ celerity_register_resource_map(array(
), ),
'phabricator-shaped-request' => 'phabricator-shaped-request' =>
array( array(
'uri' => '/res/dcd87f90/rsrc/js/application/core/ShapedRequest.js', 'uri' => '/res/59029fa9/rsrc/js/application/core/ShapedRequest.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -1827,7 +1827,7 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/b164acea/javelin.pkg.js', 'uri' => '/res/pkg/b164acea/javelin.pkg.js',
'type' => 'js', 'type' => 'js',
), ),
'e2820c7b' => 'ef420ead' =>
array( array(
'name' => 'differential.pkg.js', 'name' => 'differential.pkg.js',
'symbols' => 'symbols' =>
@ -1848,7 +1848,7 @@ celerity_register_resource_map(array(
13 => 'javelin-behavior-phabricator-object-selector', 13 => 'javelin-behavior-phabricator-object-selector',
14 => 'differential-inline-comment-editor', 14 => 'differential-inline-comment-editor',
), ),
'uri' => '/res/pkg/e2820c7b/differential.pkg.js', 'uri' => '/res/pkg/ef420ead/differential.pkg.js',
'type' => 'js', 'type' => 'js',
), ),
), ),
@ -1866,7 +1866,7 @@ celerity_register_resource_map(array(
'aphront-typeahead-control-css' => '775f5bae', 'aphront-typeahead-control-css' => '775f5bae',
'differential-changeset-view-css' => '80580cea', 'differential-changeset-view-css' => '80580cea',
'differential-core-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-local-commits-view-css' => '80580cea',
'differential-revision-add-comment-css' => '80580cea', 'differential-revision-add-comment-css' => '80580cea',
'differential-revision-comment-css' => '80580cea', 'differential-revision-comment-css' => '80580cea',
@ -1877,20 +1877,20 @@ celerity_register_resource_map(array(
'diffusion-commit-view-css' => '03ef179e', 'diffusion-commit-view-css' => '03ef179e',
'javelin-behavior' => 'b164acea', 'javelin-behavior' => 'b164acea',
'javelin-behavior-aphront-basic-tokenizer' => '540effd7', 'javelin-behavior-aphront-basic-tokenizer' => '540effd7',
'javelin-behavior-aphront-drag-and-drop' => 'e2820c7b', 'javelin-behavior-aphront-drag-and-drop' => 'ef420ead',
'javelin-behavior-aphront-drag-and-drop-textarea' => 'e2820c7b', 'javelin-behavior-aphront-drag-and-drop-textarea' => 'ef420ead',
'javelin-behavior-aphront-form-disable-on-submit' => '46547a92', 'javelin-behavior-aphront-form-disable-on-submit' => '46547a92',
'javelin-behavior-differential-accept-with-errors' => 'e2820c7b', 'javelin-behavior-differential-accept-with-errors' => 'ef420ead',
'javelin-behavior-differential-add-reviewers-and-ccs' => 'e2820c7b', 'javelin-behavior-differential-add-reviewers-and-ccs' => 'ef420ead',
'javelin-behavior-differential-comment-jump' => 'e2820c7b', 'javelin-behavior-differential-comment-jump' => 'ef420ead',
'javelin-behavior-differential-diff-radios' => 'e2820c7b', 'javelin-behavior-differential-diff-radios' => 'ef420ead',
'javelin-behavior-differential-edit-inline-comments' => 'e2820c7b', 'javelin-behavior-differential-edit-inline-comments' => 'ef420ead',
'javelin-behavior-differential-feedback-preview' => 'e2820c7b', 'javelin-behavior-differential-feedback-preview' => 'ef420ead',
'javelin-behavior-differential-keyboard-navigation' => 'e2820c7b', 'javelin-behavior-differential-keyboard-navigation' => 'ef420ead',
'javelin-behavior-differential-populate' => 'e2820c7b', 'javelin-behavior-differential-populate' => 'ef420ead',
'javelin-behavior-differential-show-more' => 'e2820c7b', 'javelin-behavior-differential-show-more' => 'ef420ead',
'javelin-behavior-phabricator-keyboard-shortcuts' => '46547a92', '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-phabricator-watch-anchor' => '46547a92',
'javelin-behavior-refresh-csrf' => '46547a92', 'javelin-behavior-refresh-csrf' => '46547a92',
'javelin-behavior-workflow' => '46547a92', 'javelin-behavior-workflow' => '46547a92',
@ -1915,12 +1915,12 @@ celerity_register_resource_map(array(
'phabricator-core-buttons-css' => '775f5bae', 'phabricator-core-buttons-css' => '775f5bae',
'phabricator-core-css' => '775f5bae', 'phabricator-core-css' => '775f5bae',
'phabricator-directory-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' => '46547a92',
'phabricator-keyboard-shortcut-manager' => '46547a92', 'phabricator-keyboard-shortcut-manager' => '46547a92',
'phabricator-object-selector-css' => '80580cea', 'phabricator-object-selector-css' => '80580cea',
'phabricator-remarkup-css' => '775f5bae', 'phabricator-remarkup-css' => '775f5bae',
'phabricator-shaped-request' => 'e2820c7b', 'phabricator-shaped-request' => 'ef420ead',
'phabricator-standard-page-view' => '775f5bae', 'phabricator-standard-page-view' => '775f5bae',
'syntax-highlighting-css' => '775f5bae', 'syntax-highlighting-css' => '775f5bae',
), ),

View file

@ -43,7 +43,7 @@ JX.install('PhabricatorShapedRequest', {
if (!waiting && !recent && this.shouldSendRequest(this._last, data)) { if (!waiting && !recent && this.shouldSendRequest(this._last, data)) {
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._callback(r);
this._min = new Date().getTime() + this.getRateLimit(); this._min = new Date().getTime() + this.getRateLimit();
@ -53,12 +53,12 @@ JX.install('PhabricatorShapedRequest', {
this.getRateLimit() this.getRateLimit()
); );
})); }));
request.listen('finally', JX.bind(this, function() { this._request.listen('finally', JX.bind(this, function() {
this._request = null; this._request = null;
})); }));
request.setData(data); this._request.setData(data);
request.setTimeout(this.getRequestTimeout()); this._request.setTimeout(this.getRequestTimeout());
request.send(); this._request.send();
} else { } else {
this._defer = setTimeout( this._defer = setTimeout(
JX.bind(this, this.trigger), JX.bind(this, this.trigger),