Skip to content

[JENKINS-73556] Disable Build while reactive parameters are updating - #1039

Merged
kinow merged 1 commit into
jenkinsci:masterfrom
Tomer9000:gh-868-block-build-while-loading
Oct 12, 2026
Merged

kinow merged 1 commit into
jenkinsci:masterfrom
Tomer9000:gh-868-block-build-while-loading

Conversation

@Tomer9000

Copy link
Copy Markdown

Fixes #868 (JENKINS-73556). Also fixes #902 (JENKINS-75793), with the same one-line fix as #960.

Problem

Users can click Build while reactive parameters are still recalculating. The build then gets empty or stale values.

Change

  • New LoadingGuard (src/main/js/LoadingGuard.ts): counts pending parameter updates.
    • While anything is pending, it disables the form's submit buttons; buttons inside parameters are left alone.
    • It blocks submit in the capture phase, which also covers Enter.
    • It shows "Calculating parameters… Ns" next to the buttons.
    • It only re-enables buttons that it disabled itself.
    • It is exposed as UnoChoice.loadingGuard, following the "global variable" idea from fix: workaround for the cascading parameters bug #357.
  • scheduleUpdate() runs every update: the initial render, referenced-parameter changes and dependent chaining. The counter goes up when an update is scheduled, so it never reaches zero between a parent finishing and its dependents starting.
  • makeStaplerProxy2 tracks calls of cascade and dynamic-reference proxies until their callback has rendered.
    • A failed call (non-2xx, network error, or a callback exception) keeps Build disabled with "A parameter failed to load. Reload the page before building."
    • Before, the parameter silently kept its old value.
  • The proxy now returns the body/callback promise, so awaiting a call also waits for its render. This is the same change as [JENKINS-75793] Fix inconsistent rendered values when using multiple reactiveChoice parameters #960. Without it, the new integration test reproduces [JENKINS-75793] Inconsistent rendered values when using multiple reactiveChoice parameters #902: a grandchild parameter is computed from its parent's previous value.

Testing done

  • src/test/js/LoadingGuard.test.ts: unit tests covering pending and overlapping updates, idempotent release, failure, leaving other scripts' disabled state alone, and blocking submit.
  • src/test/js/UnoChoice.test.ts: an integration test that loads the real UnoChoice.es6.
    • It renders a three-level cascade (Environment → Service → Version) against a fake Stapler backend with delayed headers and delayed bodies.
    • It records DOM mutations, and asserts that Build is never re-enabled before the last render and that the final values are correct.
    • It also covers failure handling and blocked submits.
    • It needed the Jest config in package.json to transform .es6.
  • Mutation check: with the guard bypassed, the integration tests fail.
  • Results: yarn test passes 38/38, 8 runs in a row, and yarn build is OK.
  • Not verified:
    • I couldn't run mvn verify locally (no JDK/Maven in this environment), so I'm relying on CI for the Java, HtmlUnit and Selenium tests.
    • I read the UI tests: none of them clicks Build.
    • I haven't tried it in a real browser or a Jenkins instance yet.

Notes for review

  • Behaviour change: a failed update used to be silent; now it blocks Build until the page is reloaded. A non-2xx response from a proxy created by makeStaplerProxy2 is now logged with console.error.
  • Input steps: on an input step page, Abort is gated together with Proceed while parameters update.
  • Nondeterminism: the integration test uses small random delays. Happy to switch to fixed staggered delays if you prefer deterministic CI.
  • CHANGES.md: I added two entries under 2.8.11; feel free to reword or drop them.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

🤖 Generated with Claude Code

@Tomer9000
Tomer9000 requested a review from a team as a code owner October 5, 2026 07:52

@kinow kinow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Tomer9000 I only allowed the CICD workflows to run here in GitHub, and had a brief look at the code, and it looks great. Thanks a ton for including tests. This looks easy to review and probably include in the next release!

I will have a better look at another time with IDE + some test jobs. Thank you!

@Tomer9000

Copy link
Copy Markdown
Author

I tested the build from this PR and it works perfectly.

@Tomer9000

Copy link
Copy Markdown
Author

@kinow Thanks for the quick look and the kind words! Do you have a rough ETA for the next release? I'm deciding whether to run a build from this branch in the meantime or wait for the release, so even a ballpark estimate would help. No pressure at all, I know this is volunteer time.

@kinow

kinow commented Oct 5, 2026

Copy link
Copy Markdown
Member

Hi @Tomer9000 , I could try to have a look at this PR this weekend, but not sure if that'd be enough for a release. After I released the last version I got two new issues created, almost immediately after the release. I haven't had time to confirm, but I suspect it'd be better to fix those issues before cutting a new release.

Next week I have to travel to another city in Spain for some days, and return the other week. I think it'd be quite optimistic to try a release this weekend. But maybe by the end of October, that could be easier to achieve.

@kinow

kinow commented Oct 5, 2026

Copy link
Copy Markdown
Member

(and thanks for the understanding!)

@kinow

kinow commented Oct 12, 2026

Copy link
Copy Markdown
Member

It's bank holiday in Spain today. Got a bit of spare time, so reviewed an issue that seemed serious but cannot be reproduced with the latest version. I'm reviewing an issue with recursive parameters, and once the PR for that one is done and reviewed/merged, I will try to test this one. Hopefully I will manage to complete everything tonight, and then maybe I'll be able to cut a new release with what we have on master. 🤞

@kinow kinow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Works as expected! I couldn't find any bug reading the code nor playing with a simple job, so I will approve it. First, I will just amend the commit to fix conflicts after rebasing, and change the format of JS comments.

Image

The Groovy I used is basically

sleep(4000)
return ['1', '2', '3', '4']

That works fine after the script is approved to run 🙂

@kinow kinow self-assigned this Oct 12, 2026
@kinow kinow added this to the 2.8.11 milestone Oct 12, 2026
@kinow
kinow force-pushed the gh-868-block-build-while-loading branch 2 times, most recently from a734510 to d20c8a3 Compare October 12, 2026 19:13
Users could submit the form while cascade/dynamic reference parameters were
still recalculating, building with empty or stale values (jenkinsciGH-868).

A LoadingGuard counts pending updates: every update is scheduled through
scheduleUpdate(), and proxy calls count until their callback has rendered.
While anything is pending, the form's submit buttons are disabled and submit
is blocked; a failed update keeps them blocked with a reload message.

The proxy now also returns the response promise, so awaiting a call waits
for its callback (JENKINS-75793, jenkinsciGH-902, same fix as jenkinsci#960).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kinow
kinow force-pushed the gh-868-block-build-while-loading branch from d20c8a3 to 92ef807 Compare October 12, 2026 19:16
@kinow

kinow commented Oct 12, 2026

Copy link
Copy Markdown
Member

Fixed conflicts after rebasing, added license headers, reformatted docs to match existing code comments (some duplication in types in TS & jsdoc-style, but we can sort that out later). Waiting for GH Actions, if it passes, will approve and merge.

@kinow kinow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! I think I have only one more issue to review that seems important for 2.8.11.

Thanks for the PR, @Tomer9000 !

@kinow
kinow merged commit a804fb9 into jenkinsci:master Oct 12, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[JENKINS-75793] Inconsistent rendered values when using multiple reactiveChoice parameters [JENKINS-73556] Nonblockable button

2 participants