Skip to content

Macro Tasks left running after failed http requests with Unknown Error, preventing protractor from completing tests #38795

@wfairclough

Description

@wfairclough

🐞 bug report

Affected Package

@angular/common/http

Is this a regression?

Yes.
Worked in @angular/[email protected]

Description

A macroTask is left running when certain http errors occur and this prevents protractor for completing since there are tasks left running in the ngZone.

🔬 Minimal Reproduction

https://github.com/wfairclough/AngularHttpMacroTaskMinimalReproduction

Run npm install

Run with npx ng serve

Open Chrome Browser to http://localhost:4200

Reproduce Bug

  1. Click Button Make Successful Request and see successul response.
  2. Click Button Check Task Counts and see the open micro and macro task counts in the ngZone.
  3. Click Button Make Failed Request and see the error response.
  4. Click Button Check Task Counts again and notice that the macroTask count is now 1.
  5. Repeat failed requests as many times as you like and the marcroTask count will just keep increasing.

🔥 Exception or Error

image

No macroTasks should be left running after this failed http request.

🌍 Your Environment

Angular Version:



     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 10.1.0
Node: 10.20.1
OS: linux x64

Angular: 10.1.1
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1001.0
@angular-devkit/build-angular     0.1001.0
@angular-devkit/build-optimizer   0.1001.0
@angular-devkit/build-webpack     0.1001.0
@angular-devkit/core              10.1.0
@angular-devkit/schematics        10.1.0
@angular/cli                      10.1.0
@ngtools/webpack                  10.1.0
@schematics/angular               10.1.0
@schematics/update                0.1001.0
rxjs                              6.6.3
typescript                        4.0.2
webpack                           4.44.1

Anything else relevant?
Error occurs in both browsers I tested with Chrome and Firefox.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions