From 7d65938bd01774433aa02920f4ffc3cf0b3d96c2 Mon Sep 17 00:00:00 2001 From: Hardik Kaurani Date: Thu, 22 Oct 2026 13:29:54 +0530 Subject: [PATCH] fix: add missing ConfigureAwait(false) in PageIterator to prevent deadlocks --- src/Microsoft.Graph.Core/Tasks/PageIterator.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.Graph.Core/Tasks/PageIterator.cs b/src/Microsoft.Graph.Core/Tasks/PageIterator.cs index f0792368e..81aafb3a2 100644 --- a/src/Microsoft.Graph.Core/Tasks/PageIterator.cs +++ b/src/Microsoft.Graph.Core/Tasks/PageIterator.cs @@ -189,7 +189,7 @@ private async Task IntrapageIterateAsync() while (_pageItemQueue.Count != 0) // && shouldContinue) { - bool shouldContinue = IsProcessPageItemCallbackAsync ? await _asyncProcessPageItemCallback(_pageItemQueue.Dequeue()) : _processPageItemCallback(_pageItemQueue.Dequeue()); + bool shouldContinue = IsProcessPageItemCallbackAsync ? await _asyncProcessPageItemCallback(_pageItemQueue.Dequeue()).ConfigureAwait(false) : _processPageItemCallback(_pageItemQueue.Dequeue()); // Cancel processing of items in the page and stop requesting more pages. if (!shouldContinue) @@ -261,7 +261,7 @@ private async Task InterpageIterateAsync(CancellationToken token) }; // if we have a request configurator, modify the request as desired then execute it to get the next page nextPageRequestInformation = _requestConfigurator == null ? nextPageRequestInformation : _requestConfigurator(nextPageRequestInformation); - _currentPage = await _requestAdapter.SendAsync(nextPageRequestInformation, (parseNode) => new TCollectionPage(), _errorMapping, token); + _currentPage = await _requestAdapter.SendAsync(nextPageRequestInformation, (parseNode) => new TCollectionPage(), _errorMapping, token).ConfigureAwait(false); var pageItems = ExtractEntityListFromParsable(_currentPage); // Add all of the items returned in the response to the queue. @@ -318,7 +318,7 @@ public async Task IterateAsync(CancellationToken token) // Iterate over the contents of queue. The queue could be from the initial page // results passed to the iterator, the results of a delta query, or from a // previously cancelled iteration that gets resumed. - bool shouldContinueInterpageIteration = await IntrapageIterateAsync(); + bool shouldContinueInterpageIteration = await IntrapageIterateAsync().ConfigureAwait(false); // Request more pages if they are available. while (shouldContinueInterpageIteration && !token.IsCancellationRequested) @@ -328,7 +328,7 @@ public async Task IterateAsync(CancellationToken token) // Iterate over items added to the queue by InterpageIterateAsync and // determine whether there are more pages to request. - shouldContinueInterpageIteration = await IntrapageIterateAsync(); + shouldContinueInterpageIteration = await IntrapageIterateAsync().ConfigureAwait(false); } }