Skip to content

Commit

Permalink
Fix: Clarify the behavior of concurrent requests in QueuedInterceptor (
Browse files Browse the repository at this point in the history
…#2347)

The previous documentation for `QueuedInterceptor` could lead to misunderstandings about how concurrent requests are handled. The explanation suggested that requests would have to wait for the previous request to complete before being initiated.

This update clarifies that requests are processed in three independent queues: `onRequest`, `onResponse`, and `onError`. These queues run in parallel.

---------

Signed-off-by: 友人A <58846244+Passer-by@users.noreply.github.com>
Co-authored-by: Alex Li <github@alexv525.com>
  • Loading branch information
Passer-by and AlexV525 authored Jan 24, 2025
1 parent 83c57de commit a92bf19
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dio/lib/src/interceptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ class _TaskQueue<T, V extends _BaseHandler> {

/// [Interceptor] in queue.
///
/// Concurrent requests will be added to the queue for interceptors.
/// `onRequest`, `onResponse`, and `onError` are processed in separate queues
/// when running concurrent requests. These queues run in parallel,
/// new requests can be initiated before previous have been completed.
class QueuedInterceptor extends Interceptor {
final _requestQueue = _TaskQueue<RequestOptions, RequestInterceptorHandler>();
final _responseQueue = _TaskQueue<Response, ResponseInterceptorHandler>();
Expand Down Expand Up @@ -430,7 +432,7 @@ class QueuedInterceptor extends Interceptor {
}
}

/// A helper class to create queued-interceptors in ease.
/// A helper class to create [QueuedInterceptor] in ease.
///
/// See also:
/// - [InterceptorsWrapper], creates [Interceptor]s in ease.
Expand Down

0 comments on commit a92bf19

Please sign in to comment.