@@ -309,36 +309,18 @@ export class HttpXhrBackend implements HttpBackend {
309
309
}
310
310
}
311
311
312
- let macroTaskCanceller : VoidFunction | undefined ;
313
-
314
- /** Tear down logic to cancel the backround macrotask. */
315
- const onLoadStart = ( ) => {
316
- macroTaskCanceller ??= createBackgroundMacroTask ( ) ;
317
- } ;
318
- const onLoadEnd = ( ) => {
319
- macroTaskCanceller ?.( ) ;
320
- } ;
321
-
322
- xhr . addEventListener ( 'loadstart' , onLoadStart ) ;
323
- xhr . addEventListener ( 'loadend' , onLoadEnd ) ;
324
-
325
312
// Fire the request, and notify the event stream that it was fired.
326
313
xhr . send ( reqBody ! ) ;
327
314
observer . next ( { type : HttpEventType . Sent } ) ;
328
315
// This is the return from the Observable function, which is the
329
316
// request cancellation handler.
330
317
return ( ) => {
331
318
// On a cancellation, remove all registered event listeners.
332
- xhr . removeEventListener ( 'loadstart' , onLoadStart ) ;
333
- xhr . removeEventListener ( 'loadend' , onLoadEnd ) ;
334
319
xhr . removeEventListener ( 'error' , onError ) ;
335
320
xhr . removeEventListener ( 'abort' , onError ) ;
336
321
xhr . removeEventListener ( 'load' , onLoad ) ;
337
322
xhr . removeEventListener ( 'timeout' , onError ) ;
338
323
339
- // Cancel the background macrotask.
340
- macroTaskCanceller ?.( ) ;
341
-
342
324
if ( req . reportProgress ) {
343
325
xhr . removeEventListener ( 'progress' , onDownProgress ) ;
344
326
if ( reqBody !== null && xhr . upload ) {
@@ -356,21 +338,3 @@ export class HttpXhrBackend implements HttpBackend {
356
338
) ;
357
339
}
358
340
}
359
-
360
- // Cannot use `Number.MAX_VALUE` as it does not fit into a 32-bit signed integer.
361
- const MAX_INT = 2147483647 ;
362
-
363
- /**
364
- * A method that creates a background macrotask of up to Number.MAX_VALUE.
365
- *
366
- * This is so that Zone.js can intercept HTTP calls, this is important for server rendering,
367
- * as the application is only rendered once the application is stabilized, meaning there are pending
368
- * macro and micro tasks.
369
- *
370
- * @returns a callback method to cancel the macrotask.
371
- */
372
- function createBackgroundMacroTask ( ) : VoidFunction {
373
- const timeout = setTimeout ( ( ) => void 0 , MAX_INT ) ;
374
-
375
- return ( ) => clearTimeout ( timeout ) ;
376
- }
0 commit comments