mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-26 19:15:09 +00:00
Fix race condition in plugin manager search results (#26819)
Search responses could arrive out of order, allowing a stale response to overwrite the table after the user had typed a newer query. Track a request id and discard responses whose id no longer matches the latest request. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1 parent
41af7d64bf
commit
b83b7bbf82
1 file changed
+7
@@ -3,12 +3,19 @@ import debounce from "lodash/debounce";
|
||||
import pluginManagerAvailable from "./templates/plugin-manager/available.hbs";
|
||||
import pluginManager from "./api/pluginManager";
|
||||
|
||||
var latestRequestId = 0;
|
||||
|
||||
function applyFilter(searchQuery) {
|
||||
// debounce reduces number of server side calls while typing
|
||||
var requestId = ++latestRequestId;
|
||||
pluginManager.availablePluginsSearch(
|
||||
searchQuery.toLowerCase().trim(),
|
||||
50,
|
||||
function (plugins) {
|
||||
// Discard stale responses so they don't overwrite results for a newer query
|
||||
if (requestId !== latestRequestId) {
|
||||
return;
|
||||
}
|
||||
var pluginsTable = document.getElementById("plugins");
|
||||
var tbody = pluginsTable.querySelector("tbody");
|
||||
var admin = pluginsTable.dataset.hasadmin === "true";
|
||||
|
||||
Reference in new issue
Block a user