Skip to content

Change detection kicked of 4 times for each XMLHttpRequest #17167

@IgorMinar

Description

@IgorMinar

@angular/[email protected]
[email protected]

screen shot 2017-06-01 at 6 23 01 pm

We fire change detection for all ReadyStateChange events + the Load event, even if all we are listening on is the Load event.

I looked into this and it seems that there is something wrong with the XHR patch in zone.js or less likely in NgZone.

The issue repro's with @angular/http or even with plain XMLHttpRequest object used as follows:

    var xhr = new XMLHttpRequest();
    xhr.open('GET', 'assets/data/data.json');
    xhr.onload = () => {
      console.log(xhr.responseText)
      this.processData(JSON.parse(xhr.responseText));
    };
    xhr.send();

If we switch over to using fetch (which is patched differently by zone.js), we trigger just one change detection.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions