As per [this comment](https://github.com/elastic/elasticsearch/pull/93375#discussion_r1093607808) the changes in #90977 may leak the thread context of the last-completing task into the response to the list-tasks API. We need to address this before these changes are released, which is planned for 8.7.0.
server/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/TransportListTasksAction.java
allMatchedTasksRemovedListener.onFailure(e);
                return;
            }
            removalRefs.decRef();
            collectionComplete.set(true);
            if (future.isDone()) {
                
                allMatchedTasksRemovedListener.onResponse(null);
            } else {
                future.addListener(
                    new ThreadedActionListener<>(
                        clusterService.threadPool().executor(ThreadPool.Names.MANAGEMENT),
                        false,
                        allMatchedTasksRemovedListener
                    )
                );
                var cancellable = clusterService.threadPool()
                    .schedule(
                        () -> future.onFailure(new ElasticsearchTimeoutException("Timed out waiting for completion of tasks")),
                        requireNonNullElse(request.getTimeout(), DEFAULT_WAIT_FOR_COMPLETION_TIMEOUT),
                        ThreadPool.Names.SAME
                    );
                future.addListener(ActionListener.wrap(cancellable::cancel));
            }
        } else {
            super.processTasks(request, operation, nodeOperation);
        }
    }
}