Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Bound request queue #28

Merged
merged 7 commits into from
Oct 19, 2017
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.11.1] - 2017-10-19
### Fixed
- :snail: :racehorse: Fixed a performance issue. In 0.11.0 we introduced an internal request queue to fix some bugs. This request queue was boundless and in certain cases it could become really large and slow down the app. Now, we remove old requests from this queue when they are no longer needed, keeping its size under control. Originally reported in https://github.com/plotly/dash-renderer/issues/27

## [0.11.0] - 2017-09-28
### Fixed
- 🐞 Previously, old requests could override new requests if their response was longer than the new one.
Expand Down
3 changes: 2 additions & 1 deletion dash_renderer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
# command in the dash_html_components package which printed out:
# `dash_html_components.__init__: module references __file__`
# TODO - Understand this better
from .version import __version__
# from .version import __version__
__version__ = '0.11.1'
__file__

# Dash renderer's dependencies get loaded in a special order by the server:
Expand Down
2 changes: 1 addition & 1 deletion dash_renderer/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.11.0'
__version__ = '0.11.1'
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-renderer",
"version": "0.11.0",
"version": "0.11.1",
"description": "render dash components in react",
"main": "src/index.js",
"scripts": {
Expand Down
23 changes: 22 additions & 1 deletion src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@ export function notifyObservers(payload) {
const updateRequestQueue = rejected => {
const postRequestQueue = getState().requestQueue
const thisRequestIndex = getThisRequestIndex();
if (thisRequestIndex === -1) {
// It was already pruned away
return;
}
const updatedQueue = adjust(
merge(__, {
status: res.status,
Expand All @@ -406,15 +410,32 @@ export function notifyObservers(payload) {
thisRequestIndex,
postRequestQueue
);
// We don't need to store any requests before this one
const thisControllerId = postRequestQueue[
thisRequestIndex].controllerId;
const prunedQueue = updatedQueue.filter(
(queueItem, index) => {
return (
queueItem.controllerId !== thisControllerId ||
index >= thisRequestIndex
);
}
);

dispatch(setRequestQueue(updatedQueue));
dispatch(setRequestQueue(prunedQueue));
}

const isRejected = () => {
const latestRequestIndex = findLastIndex(
propEq('controllerId', newRequestQueue[i].controllerId),
getState().requestQueue
);
/*
* Note that if the latest request is still `loading`
* or even if the latest request failed,
* we still reject this response in favor of waiting
* for the latest request to finish.
*/
const rejected = latestRequestIndex > getThisRequestIndex();
return rejected;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/test_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@ def update_output(value):
)

self.request_queue_assertions(
expected_length=call_count.value, check_rejected=False)
expected_length=1,
check_rejected=False)

assert_clean_console(self)

Expand Down Expand Up @@ -1535,5 +1536,4 @@ def update_output(n_clicks):
'return window.store.getState().requestQueue'
)
self.assertFalse(request_queue[0]['rejected'])
self.assertTrue(request_queue[1]['rejected'])
self.assertFalse(request_queue[2]['rejected'])
self.assertEqual(len(request_queue), 1)