What the hell is Zone.js and why is it in my Angular 2?
Pete Mertz
8069

Speaking of zone.js perhaps you could shed some light on a new problem I’m encountering with my Angular app and zone.js.

I am running an Angular 4 UI compiled with webpack 3.10.n and I just upgraded to zone.js 0.8.4. because I want to use this neat new multi-select which required that I be on Angular 4 which required that I be on zone.js 0.8.4

So my app is running fine as it did on Angular 2 and I was getting clean script displays on the console using Developer Tools in Google Chrome prior to my changes.

But now am getting these errors the ‘net ERR CONNECTION REFUSED error but only in Google Chrome browser. When I used IE I have no problems.

The zone.js code and error (look at the bottom of code about 3 lines up….

start of code….

function scheduleTask(task) {
XMLHttpRequest[XHR_SCHEDULED] = false;
var data = task.data;
// remove existing event listener
var listener = data.target[XHR_LISTENER];
if (listener) {
data.target.removeEventListener('readystatechange', listener);
}
var newListener = data.target[XHR_LISTENER] = function () {
if (data.target.readyState === data.target.DONE) {
// sometimes on some browsers XMLHttpRequest will fire onreadystatechange with
// readyState=4 multiple times, so we need to check task state here
if (!data.aborted && XMLHttpRequest[XHR_SCHEDULED] && task.state === 'scheduled') {
task.invoke();
}
}
};
data.target.addEventListener('readystatechange', newListener);
var storedTask = data.target[XHR_TASK];
if (!storedTask) {
data.target[XHR_TASK] = task;
}
sendNative.apply(data.target, data.args); ///' error message Failed to load resource: net::ERR_CONNECTION_REFUSED ////
XMLHttpRequest[XHR_SCHEDULED] = true;
return task;
}

end of code………….

I don’t even know what the scheduled task would be or why zone.js is processing this XHR TASK for data.
My observable calls are in an injected service and they are the only way that I pass Json data back and forth through http request/responses. All this works fine. Can’t figure out why this task attempt is made with no data on Google Chrome.

Like what you read? Give Brian Quinn a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.