From e5d7249f4556b778785ca83424e2b10e4d441bbf Mon Sep 17 00:00:00 2001 From: BryanSchroeder Date: Mon, 30 Dec 2024 10:21:10 -0500 Subject: [PATCH 1/8] attempting to make polling requests not eat bandwidth --- dash/dash-renderer/src/actions/callbacks.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/dash/dash-renderer/src/actions/callbacks.ts b/dash/dash-renderer/src/actions/callbacks.ts index 23da0a3ff3..1ccd17d62f 100644 --- a/dash/dash-renderer/src/actions/callbacks.ts +++ b/dash/dash-renderer/src/actions/callbacks.ts @@ -439,6 +439,7 @@ function handleServerside( const fetchCallback = () => { const headers = getCSRFHeader() as any; let url = `${urlBase(config)}_dash-update-component`; + let new_body = body const addArg = (name: string, value: string) => { let delim = '?'; @@ -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 + let tmp_body = JSON.parse(new_body) + for (let i = 0; i < tmp_body.inputs.length; i++) { + tmp_body.inputs[i]['value'] = null; + } + for (let i = 0; i < tmp_body?.state.length; i++) { + tmp_body.state[i]['value'] = null; + } + new_body = JSON.stringify(tmp_body) } if (moreArgs) { @@ -464,7 +473,7 @@ function handleServerside( mergeDeepRight(config.fetch, { method: 'POST', headers, - body + body: new_body, }) ); }; From 4059c3e8eec16acf9afbae0b15d568624e5d502a Mon Sep 17 00:00:00 2001 From: BryanSchroeder Date: Mon, 30 Dec 2024 13:07:26 -0500 Subject: [PATCH 2/8] Allowing state to have a fallback of `[]` --- dash/dash-renderer/src/actions/callbacks.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dash/dash-renderer/src/actions/callbacks.ts b/dash/dash-renderer/src/actions/callbacks.ts index 1ccd17d62f..847ece68b1 100644 --- a/dash/dash-renderer/src/actions/callbacks.ts +++ b/dash/dash-renderer/src/actions/callbacks.ts @@ -457,7 +457,7 @@ function handleServerside( for (let i = 0; i < tmp_body.inputs.length; i++) { tmp_body.inputs[i]['value'] = null; } - for (let i = 0; i < tmp_body?.state.length; i++) { + for (let i = 0; i < (tmp_body?.state || []).length; i++) { tmp_body.state[i]['value'] = null; } new_body = JSON.stringify(tmp_body) From 9c254553df06bd8f2c449018e9c38dc247dc17dc Mon Sep 17 00:00:00 2001 From: BryanSchroeder Date: Mon, 30 Dec 2024 13:29:14 -0500 Subject: [PATCH 3/8] fixing for lint --- dash/dash-renderer/src/actions/callbacks.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dash/dash-renderer/src/actions/callbacks.ts b/dash/dash-renderer/src/actions/callbacks.ts index 847ece68b1..fdd6570e73 100644 --- a/dash/dash-renderer/src/actions/callbacks.ts +++ b/dash/dash-renderer/src/actions/callbacks.ts @@ -439,7 +439,7 @@ function handleServerside( const fetchCallback = () => { const headers = getCSRFHeader() as any; let url = `${urlBase(config)}_dash-update-component`; - let new_body = body + let new_body = body; const addArg = (name: string, value: string) => { let delim = '?'; @@ -453,14 +453,14 @@ function handleServerside( if (job) addArg('job', job); // clear inputs as background callback doesnt need inputs, just verify for context - let tmp_body = JSON.parse(new_body) + const tmp_body = JSON.parse(new_body); for (let i = 0; i < tmp_body.inputs.length; i++) { tmp_body.inputs[i]['value'] = null; } for (let i = 0; i < (tmp_body?.state || []).length; i++) { tmp_body.state[i]['value'] = null; } - new_body = JSON.stringify(tmp_body) + new_body = JSON.stringify(tmp_body); } if (moreArgs) { @@ -473,7 +473,7 @@ function handleServerside( mergeDeepRight(config.fetch, { method: 'POST', headers, - body: new_body, + body: new_body }) ); }; From e2c3bace7d6fe896ac38da6fdf4138b28e23b189 Mon Sep 17 00:00:00 2001 From: BryanSchroeder Date: Mon, 6 Jan 2025 11:27:47 -0500 Subject: [PATCH 4/8] swapping for camelCase --- dash/dash-renderer/src/actions/callbacks.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dash/dash-renderer/src/actions/callbacks.ts b/dash/dash-renderer/src/actions/callbacks.ts index fdd6570e73..bde7976a64 100644 --- a/dash/dash-renderer/src/actions/callbacks.ts +++ b/dash/dash-renderer/src/actions/callbacks.ts @@ -439,7 +439,7 @@ function handleServerside( const fetchCallback = () => { const headers = getCSRFHeader() as any; let url = `${urlBase(config)}_dash-update-component`; - let new_body = body; + let newBody = body; const addArg = (name: string, value: string) => { let delim = '?'; @@ -453,14 +453,14 @@ function handleServerside( if (job) addArg('job', job); // clear inputs as background callback doesnt need inputs, just verify for context - const tmp_body = JSON.parse(new_body); + const tmpBody = JSON.parse(new_body); for (let i = 0; i < tmp_body.inputs.length; i++) { - tmp_body.inputs[i]['value'] = null; + tmpBody.inputs[i]['value'] = null; } for (let i = 0; i < (tmp_body?.state || []).length; i++) { - tmp_body.state[i]['value'] = null; + tmpBody.state[i]['value'] = null; } - new_body = JSON.stringify(tmp_body); + newBody = JSON.stringify(tmpBody); } if (moreArgs) { From 4d253290a5b006373031691ec36db74f35167f2a Mon Sep 17 00:00:00 2001 From: BryanSchroeder Date: Mon, 6 Jan 2025 11:53:02 -0500 Subject: [PATCH 5/8] fixing last camelCase --- dash/dash-renderer/src/actions/callbacks.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dash/dash-renderer/src/actions/callbacks.ts b/dash/dash-renderer/src/actions/callbacks.ts index bde7976a64..335931844d 100644 --- a/dash/dash-renderer/src/actions/callbacks.ts +++ b/dash/dash-renderer/src/actions/callbacks.ts @@ -473,7 +473,7 @@ function handleServerside( mergeDeepRight(config.fetch, { method: 'POST', headers, - body: new_body + body: newBody }) ); }; From 4b67283eca9c6bbdd9217551dfe8d1da90937b0b Mon Sep 17 00:00:00 2001 From: BryanSchroeder Date: Mon, 6 Jan 2025 12:10:21 -0500 Subject: [PATCH 6/8] fixing other errors --- dash/dash-renderer/src/actions/callbacks.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dash/dash-renderer/src/actions/callbacks.ts b/dash/dash-renderer/src/actions/callbacks.ts index 335931844d..0609af94f9 100644 --- a/dash/dash-renderer/src/actions/callbacks.ts +++ b/dash/dash-renderer/src/actions/callbacks.ts @@ -453,11 +453,11 @@ function handleServerside( if (job) addArg('job', job); // clear inputs as background callback doesnt need inputs, just verify for context - const tmpBody = JSON.parse(new_body); - for (let i = 0; i < tmp_body.inputs.length; i++) { + const tmpBody = JSON.parse(newBody); + for (let i = 0; i < tmpBody.inputs.length; i++) { tmpBody.inputs[i]['value'] = null; } - for (let i = 0; i < (tmp_body?.state || []).length; i++) { + for (let i = 0; i < (tmpBody?.state || []).length; i++) { tmpBody.state[i]['value'] = null; } newBody = JSON.stringify(tmpBody); From 214a798412ea85e9c1ba4d5c671f1f1b65a8e175 Mon Sep 17 00:00:00 2001 From: BryanSchroeder Date: Tue, 7 Jan 2025 09:57:10 -0500 Subject: [PATCH 7/8] updating changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e1bd29118..c685027fa6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ 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 From 701cd68f1cd949a5b792c0398faaf84ee5c804c7 Mon Sep 17 00:00:00 2001 From: BryanSchroeder Date: Wed, 8 Jan 2025 10:17:31 -0500 Subject: [PATCH 8/8] touch to rerun tests --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c685027fa6..c13f22c1ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). ## 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