Skip to content

Commit aeb618e

Browse files
committed
Update comment on cancel()
1 parent 0d33ccf commit aeb618e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pkgs/http/lib/src/browser_client.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,15 @@ Future<void> _readStreamBody(BaseRequest request, Response response,
196196
// a completed state at that point.
197197
await reader.cancel().toDart;
198198
} catch (e, s) {
199+
// It is possible for reader.cancel() to throw. This happens either
200+
// because the stream has already been in an error state (in which case
201+
// we would have called addErrorSync() before and don't need to re-
202+
// report the error here), or because of an issue here (MDN says the
203+
// method can throw if "The source object is not a
204+
// ReadableStreamDefaultReader, or the stream has no owner."). Both of
205+
// these don't look applicable here, but we want to ensure a new error
206+
// in cancel() is surfaced to the caller.
199207
if (!hadError) {
200-
// If the stream enters an error state, .cancel() will rethrow that
201-
// error. We want to ignore that since we would have added it to the
202-
// stream already.
203208
_rethrowAsClientException(e, s, request);
204209
}
205210
}

0 commit comments

Comments
 (0)