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

Replace Prototype.js with native JavaScript #90

Merged
merged 1 commit into from
May 17, 2023

Conversation

basil
Copy link
Member

@basil basil commented May 16, 2023

See JENKINS-70906. Jenkins core currently uses Prototype 1.7, released on November 15, 2010. The latest version is Prototype 1.7.3, released on September 22, 2015. When an attempt was made to upgrade to 1.7.3 in 2018 in JENKINS-49319, the change had to be reverted. Since this library has been unmaintained for the past 8 years, this PR removes any usages of it in favor of native JavaScript APIs. To test this, I installed this plugin on a custom build of Jenkins that had Prototype ripped out (a local project branch), clicked on the Refresh link, and verified in my browser's debugger that the POST request was submitted successfully as before and that the "Refresh scheduled" tooltip was displayed.

@basil basil force-pushed the remove-prototype branch from 2ca86ae to c32096a Compare May 16, 2023 03:29
@PierreBtz
Copy link
Contributor

@basil thanks for the fix!

I performed some tests running mvn hpi:run -Djenkins.version=2.404 (disabling prototype) with and without it and I indeed see the prototype related error going away with your fix.

However I noticed an Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource. appearing in Firefox and the POST request being aborted with a NS_BINDING_ABORTED state. At first glance I'd say it's not an issue with your fix, I also see the title.svg and logo.svg GET requests being aborted the same way but I'd like to take some time to understand better what's going on.

On a side note, when refreshing the user config page, I noticed a prototype related error that you might (or not) know about, so as a FYI:

updateListBox http://***:8080/jenkins/adjuncts/20ed464f/lib/form/select/select.js:95
    <anonymous> http://***:8080/jenkins/adjuncts/20ed464f/lib/form/select/select.js:118
    h http://***:8080/jenkins/static/20ed464f/scripts/hudson-behavior.js:1787
    refillOnChange http://***:8080/jenkins/static/20ed464f/scripts/hudson-behavior.js:1809
    <anonymous> http://***:8080/jenkins/adjuncts/20ed464f/lib/form/select/select.js:116
    applySubtree http://***:8080/jenkins/static/20ed464f/scripts/behavior.js:135
    applySubtree http://***:8080/jenkins/static/20ed464f/scripts/behavior.js:126
    applySubtree http://***:8080/jenkins/static/20ed464f/scripts/behavior.js:107
    apply http://***:8080/jenkins/static/20ed464f/scripts/behavior.js:90
    start http://***:8080/jenkins/static/20ed464f/scripts/behavior.js:85
    onload http://***:8080/jenkins/static/20ed464f/scripts/behavior.js:152
    onload http://***:8080/jenkins/static/20ed464f/scripts/behavior.js:152
    addLoadEvent http://***:8080/jenkins/static/20ed464f/scripts/behavior.js:151
    createSearchBox http://***:8080/jenkins/static/20ed464f/scripts/hudson-behavior.js:2224
    <anonymous> http://***:8080/jenkins/adjuncts/20ed464f/jenkins/views/JenkinsHeader/search-box.js:4
    <anonymous> http://***:8080/jenkins/adjuncts/20ed464f/jenkins/views/JenkinsHeader/search-box.js:6
behavior.js:138:23
    applySubtree http://***:8080/jenkins/static/20ed464f/scripts/behavior.js:138
    applySubtree http://***:8080/jenkins/static/20ed464f/scripts/behavior.js:126
    applySubtree http://***:8080/jenkins/static/20ed464f/scripts/behavior.js:107
    apply http://***:8080/jenkins/static/20ed464f/scripts/behavior.js:90
    start http://***:8080/jenkins/static/20ed464f/scripts/behavior.js:85
    onload http://***:8080/jenkins/static/20ed464f/scripts/behavior.js:152
    onload http://***:8080/jenkins/static/20ed464f/scripts/behavior.js:152
    (Async: EventHandlerNonNull)
    addLoadEvent http://***:8080/jenkins/static/20ed464f/scripts/behavior.js:151
    createSearchBox http://***:8080/jenkins/static/20ed464f/scripts/hudson-behavior.js:2224
    <anonymous> http://***:8080/jenkins/adjuncts/20ed464f/jenkins/views/JenkinsHeader/search-box.js:4
    <anonymous> http://***:8080/jenkins/adjuncts/20ed464f/jenkins/views/JenkinsHeader/search-box.js:6

@basil
Copy link
Member Author

basil commented May 16, 2023

I think that NetworkError is because the page is reloaded before the result from the server is processed. But that seems to be the intended behavior of this code, which makes a best-effort asynchronous request to poke the server before refreshing the page.

The other error you posted is JENKINS-70922, and there is an open pull request to fix it in jenkinsci/jenkins#7982.

@PierreBtz
Copy link
Contributor

Indeed after looking at it a bit more I'm satisfied this "error" doesn't impact the feature.
Thanks for taking the time to review this.

@PierreBtz PierreBtz merged commit 62ca0c9 into jenkinsci:master May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants