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

Stripping Input Data from Background Callback Polling #3113

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
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 @@ -9,6 +9,10 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- [#3080](https://github.com/plotly/dash/pull/3080) Fix docstring generation for components using single-line or nonstandard-indent leading comments
- [#3103](https://github.com/plotly/dash/pull/3103) Fix Graph component becomes unresponsive if an invalid figure is passed

## Changed
- [#3113](https://github.com/plotly/dash/pull/3113) Adjusted background polling requests to strip the data from the request, this allows for context to flow as normal. This addresses issue [#3111](https://github.com/plotly/dash/pull/3111)


## [2.18.2] - 2024-11-04

## Fixed
Expand Down
21 changes: 15 additions & 6 deletions dash/dash-renderer/src/actions/callbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ function handleServerside(
const fetchCallback = () => {
const headers = getCSRFHeader() as any;
let url = `${urlBase(config)}_dash-update-component`;
let newBody = body;

const addArg = (name: string, value: string) => {
let delim = '?';
Expand All @@ -447,11 +448,19 @@ function handleServerside(
}
url = `${url}${delim}${name}=${value}`;
};
if (cacheKey) {
addArg('cacheKey', cacheKey);
}
if (job) {
addArg('job', job);
if (cacheKey || job) {
if (cacheKey) addArg('cacheKey', cacheKey);
if (job) addArg('job', job);

// clear inputs as background callback doesnt need inputs, just verify for context
const tmpBody = JSON.parse(newBody);
for (let i = 0; i < tmpBody.inputs.length; i++) {
tmpBody.inputs[i]['value'] = null;
}
for (let i = 0; i < (tmpBody?.state || []).length; i++) {
tmpBody.state[i]['value'] = null;
}
newBody = JSON.stringify(tmpBody);
}

if (moreArgs) {
Expand All @@ -464,7 +473,7 @@ function handleServerside(
mergeDeepRight(config.fetch, {
method: 'POST',
headers,
body
body: newBody
})
);
};
Expand Down