Skip to content

Conversation

@jtnord
Copy link
Member

@jtnord jtnord commented Jan 22, 2026

calling renderOnDemand can cause the DOM to be manipulated aynchronously due to function calls going to the Jenkins server (e.g. stapler/bound/xxx/render). When this occurs if there is a subsequent change to the dropdown selection before this completes, when the HTML is finally obtained from Jenkins it is inserted into the DOM, but it is inserted as if it is still the selected option (ie it is not disable for the form).

renderOnDemand takes a callback function that will be called when the DOM manipulation is complete, however the updateDropDownList did not pass any function.

We now pass a function that manipulates the just added HTML if the selected item is in fact no longer selected.

Fixes #16833

Testing done

  • Commented out the fix
    // our form div has changed (but the index is stable) so go and re-get the new domtree
    var subForm = buildSubForms(e)[idx];
    updateDropDownFormRowVisibility(subForm, false);
  • Ran mvn test -Dtest=SshSlavesPluginTest#newAgent in a loop.

Observed that the test failed ~ 1 time in 10 and that the newly added console log (**** renderOnDemandCallback, selection no longer valid, form submission would have been corrupted) always appeared when the test would fail (and very rarely appeared otherwise)

  • Reintroduced the fix
  • Ran mvn test -Dtest=SshSlavesPluginTest#newAgent again.

Observed I still see the newly introduced console log ~ 1 time in 10m but the test did not fail in > 800 runs.

Screenshots (UI changes only)

Before

After

Proposed changelog entries

  • Submitting a form would in rare cases, lead to an error (Got type array but no lister class found for type...)

Proposed changelog category

/label

Proposed upgrade guidelines

N/A

Submitter checklist

  • The issue, if it exists, is well-described.
  • The changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developers, depending on the change) and are in the imperative mood (see examples). Fill in the Proposed upgrade guidelines section only if there are breaking changes or changes that may require extra steps from users during upgrade.
  • There is automated testing or an explanation as to why this change has no tests.
  • New public classes, fields, and methods are annotated with @Restricted or have @since TODO Javadocs, as appropriate.
  • New deprecations are annotated with @Deprecated(since = "TODO") or @Deprecated(forRemoval = true, since = "TODO"), if applicable.
  • UI changes do not introduce regressions when enforcing the current default rules of Content Security Policy Plugin. In particular, new or substantially changed JavaScript is not defined inline and does not call eval to ease future introduction of Content Security Policy (CSP) directives (see documentation).
  • For dependency updates, there are links to external changelogs and, if possible, full differentials.
  • For new APIs and extension points, there is a link to at least one consumer.

Desired reviewers

@mention

Before the changes are marked as ready-for-merge:

Maintainer checklist

  • There are at least two (2) approvals for the pull request and no outstanding requests for change.
  • Conversations in the pull request are over, or it is explicit that a reviewer is not blocking the change.
  • Changelog entries in the pull request title and/or Proposed changelog entries are accurate, human-readable, and in the imperative mood.
  • Proper changelog labels are set so that the changelog can be generated automatically.
  • If the change needs additional upgrade steps from users, the upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).
  • If it would make sense to backport the change to LTS, be a Bug or Improvement, and either the issue or pull request must be labeled as lts-candidate to be considered.

@jtnord jtnord added major-bug For changelog: Major bug. Will be highlighted on the top of the changelog lts-candidate When fixed, this issue should be considered for backporting to the LTS line labels Jan 22, 2026
…eb response is slow

calling renderOnDemand can cause the dom to be manipulated
aynchronouslyi due to function calls going to the Jenkins server (e.g.
stapler/bound/xxx/render).  When this occurs if there is a subsequent change to the
dropdown selection before this completes, when the HTML is finally
obtained from Jenkins it is inserted into the DOM, but it is inserted as
if it is still the selected option (ie it is not disable for the form).

renderOnDemand takes a callback function that will be called when the
DOM manipulation is complete, however the updateDropDownList did not
pass any function.

We now pass a function that manipulates the just added HTML if the
selected item is in fact no longer selected.
Comment on lines 1719 to 1721
// our form div has changed (but the index is stable) so go and re-get the new domtree
var subForm = buildSubForms(e)[idx];
updateDropDownFormRowVisibility(subForm, false);
Copy link
Member Author

@jtnord jtnord Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for testing these 3 lines where commented out to show the previous console line was printed and the test failed ~ 1:10
Then re introduced and the test passed 100 times in a row

@jtnord jtnord marked this pull request as ready for review January 23, 2026 00:59
Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@timja timja requested a review from a team January 23, 2026 09:14
@jtnord jtnord changed the title [JENKINS-76249] Fix form submission when a dropdown changes and the eb response is slow [JENKINS-76249] Fix form submission when a dropdown changes and the be response is slow Jan 23, 2026
@jtnord jtnord changed the title [JENKINS-76249] Fix form submission when a dropdown changes and the be response is slow [JENKINS-76249] Fix form submission when a dropdown changes and the back end response is slow Jan 23, 2026
@timja
Copy link
Member

timja commented Jan 23, 2026

/label ready-for-merge


This PR is now ready for merge, after ~24 hours, we will merge it if there's no negative feedback.

Thanks!

@comment-ops-bot comment-ops-bot bot added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Jan 23, 2026
Copy link

@A1exKH A1exKH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@MarkEWaite MarkEWaite merged commit 46a0a75 into jenkinsci:master Jan 24, 2026
17 checks passed
shalinisudarsan pushed a commit to shalinisudarsan/jenkins that referenced this pull request Jan 29, 2026
…ack end response is slow (jenkinsci#26161)

* [JENKINS-76249] Fix form submission when a dropdown changes and the web response is slow

calling renderOnDemand can cause the dom to be manipulated
aynchronouslyi due to function calls going to the Jenkins server (e.g.
stapler/bound/xxx/render).  When this occurs if there is a subsequent change to the
dropdown selection before this completes, when the HTML is finally
obtained from Jenkins it is inserted into the DOM, but it is inserted as
if it is still the selected option (ie it is not disable for the form).

renderOnDemand takes a callback function that will be called when the
DOM manipulation is complete, however the updateDropDownList did not
pass any function.

We now pass a function that manipulates the just added HTML if the
selected item is in fact no longer selected.

* Update war/src/main/webapp/scripts/hudson-behavior.js

Co-authored-by: Tim Jacomb <[email protected]>

* Apply suggestions from code review

Co-authored-by: Tim Jacomb <[email protected]>

---------

Co-authored-by: Tim Jacomb <[email protected]>
(cherry picked from commit 46a0a75)
shalinisudarsan pushed a commit to shalinisudarsan/jenkins that referenced this pull request Jan 29, 2026
…ack end response is slow (jenkinsci#26161)

* [JENKINS-76249] Fix form submission when a dropdown changes and the web response is slow

calling renderOnDemand can cause the dom to be manipulated
aynchronouslyi due to function calls going to the Jenkins server (e.g.
stapler/bound/xxx/render).  When this occurs if there is a subsequent change to the
dropdown selection before this completes, when the HTML is finally
obtained from Jenkins it is inserted into the DOM, but it is inserted as
if it is still the selected option (ie it is not disable for the form).

renderOnDemand takes a callback function that will be called when the
DOM manipulation is complete, however the updateDropDownList did not
pass any function.

We now pass a function that manipulates the just added HTML if the
selected item is in fact no longer selected.

* Update war/src/main/webapp/scripts/hudson-behavior.js

Co-authored-by: Tim Jacomb <[email protected]>

* Apply suggestions from code review

Co-authored-by: Tim Jacomb <[email protected]>

---------

Co-authored-by: Tim Jacomb <[email protected]>
(cherry picked from commit 46a0a75)
shalinisudarsan pushed a commit to shalinisudarsan/jenkins that referenced this pull request Jan 29, 2026
…ack end response is slow (jenkinsci#26161)

* [JENKINS-76249] Fix form submission when a dropdown changes and the web response is slow

calling renderOnDemand can cause the dom to be manipulated
aynchronouslyi due to function calls going to the Jenkins server (e.g.
stapler/bound/xxx/render).  When this occurs if there is a subsequent change to the
dropdown selection before this completes, when the HTML is finally
obtained from Jenkins it is inserted into the DOM, but it is inserted as
if it is still the selected option (ie it is not disable for the form).

renderOnDemand takes a callback function that will be called when the
DOM manipulation is complete, however the updateDropDownList did not
pass any function.

We now pass a function that manipulates the just added HTML if the
selected item is in fact no longer selected.

* Update war/src/main/webapp/scripts/hudson-behavior.js

Co-authored-by: Tim Jacomb <[email protected]>

* Apply suggestions from code review

Co-authored-by: Tim Jacomb <[email protected]>

---------

Co-authored-by: Tim Jacomb <[email protected]>
(cherry picked from commit 46a0a75)
meetgoti07 pushed a commit to meetgoti07/jenkins that referenced this pull request Jan 29, 2026
…ack end response is slow (jenkinsci#26161)

* [JENKINS-76249] Fix form submission when a dropdown changes and the web response is slow

calling renderOnDemand can cause the dom to be manipulated
aynchronouslyi due to function calls going to the Jenkins server (e.g.
stapler/bound/xxx/render).  When this occurs if there is a subsequent change to the
dropdown selection before this completes, when the HTML is finally
obtained from Jenkins it is inserted into the DOM, but it is inserted as
if it is still the selected option (ie it is not disable for the form).

renderOnDemand takes a callback function that will be called when the
DOM manipulation is complete, however the updateDropDownList did not
pass any function.

We now pass a function that manipulates the just added HTML if the
selected item is in fact no longer selected.

* Update war/src/main/webapp/scripts/hudson-behavior.js

Co-authored-by: Tim Jacomb <[email protected]>

* Apply suggestions from code review

Co-authored-by: Tim Jacomb <[email protected]>

---------

Co-authored-by: Tim Jacomb <[email protected]>
shalinisudarsan pushed a commit to shalinisudarsan/jenkins that referenced this pull request Jan 30, 2026
…ack end response is slow (jenkinsci#26161)

* [JENKINS-76249] Fix form submission when a dropdown changes and the web response is slow

calling renderOnDemand can cause the dom to be manipulated
aynchronouslyi due to function calls going to the Jenkins server (e.g.
stapler/bound/xxx/render).  When this occurs if there is a subsequent change to the
dropdown selection before this completes, when the HTML is finally
obtained from Jenkins it is inserted into the DOM, but it is inserted as
if it is still the selected option (ie it is not disable for the form).

renderOnDemand takes a callback function that will be called when the
DOM manipulation is complete, however the updateDropDownList did not
pass any function.

We now pass a function that manipulates the just added HTML if the
selected item is in fact no longer selected.

* Update war/src/main/webapp/scripts/hudson-behavior.js

Co-authored-by: Tim Jacomb <[email protected]>

* Apply suggestions from code review

Co-authored-by: Tim Jacomb <[email protected]>

---------

Co-authored-by: Tim Jacomb <[email protected]>
(cherry picked from commit 46a0a75)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lts-candidate When fixed, this issue should be considered for backporting to the LTS line major-bug For changelog: Major bug. Will be highlighted on the top of the changelog ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[JENKINS-76249] form submission data is occasionally garbage

6 participants