Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS $http.get() takes up to 10-20 seconds in Chrome, works fine in Firefox

I'm encountering an odd error with AngularJS / Google Chrome. When I do an $http.get() it takes up to 18 seconds before it actually completes. It seems to keep at "PENDING" for the "OPTIONS" method:

http://i.imgur.com/yEozFdm.png

The server that serves the pages is Mongoose, the one @ localhost:5000 is Flask, who returns the following headers in order for the CORS to work.

@mod.after_request
def after_request(response):
    response.headers.add('Access-Control-Allow-Origin', 'http://localhost:8080')
    response.headers.add('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
    response.headers.add('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type,     Accept')

Anyone knows why Chrome is delaying the OPTIONS request? (From the flask server debug console, it seems that the OPTIONS method really only arrives 10-20 seconds after the page has been reloaded). It seems to work fine in Firefox.

like image 389
Busata Avatar asked Oct 06 '13 11:10

Busata


1 Answers

It seems to have been solved once I disabled the "Predict network actions to improve page load performance" option. Very odd, perhaps I should leave this question open for if someone could give a possible reason for this?

Edit: See comments for the reason!

like image 130
Busata Avatar answered Oct 06 '22 00:10

Busata