MCPcopy
hub / github.com/angular/angular / handle

Method handle

packages/common/http/src/fetch.ts:84–112  ·  view source on GitHub ↗
(request: HttpRequest<any>)

Source from the content-addressed store, hash-verified

82 private readonly maxResponseSize = inject(HTTP_FETCH_MAX_RESPONSE_SIZE);
83
84 handle(request: HttpRequest<any>): Observable<HttpEvent<any>> {
85 return new Observable((observer) => {
86 const aborter = new AbortController();
87
88 this.doRequest(request, aborter.signal, observer).then(noop, (error) =>
89 observer.error(new HttpErrorResponse({error})),
90 );
91
92 let timeoutId: ReturnType<typeof setTimeout> | undefined;
93 if (request.timeout) {
94 // TODO: Replace with AbortSignal.any([aborter.signal, AbortSignal.timeout(request.timeout)])
95 // when AbortSignal.any support is Baseline widely available (NET nov. 2026)
96 timeoutId = this.ngZone.runOutsideAngular(() =>
97 setTimeout(() => {
98 if (!aborter.signal.aborted) {
99 aborter.abort(new DOMException('signal timed out', 'TimeoutError'));
100 }
101 }, request.timeout),
102 );
103 }
104
105 return () => {
106 if (timeoutId !== undefined) {
107 clearTimeout(timeoutId);
108 }
109 aborter.abort();
110 };
111 });
112 }
113
114 private async doRequest(
115 request: HttpRequest<any>,

Callers

nothing calls this directly

Calls 7

doRequestMethod · 0.95
setTimeoutFunction · 0.85
clearTimeoutFunction · 0.85
thenMethod · 0.65
errorMethod · 0.65
abortMethod · 0.65
runOutsideAngularMethod · 0.45

Tested by

no test coverage detected