Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

$http requests are sometimes queued and not triggered as expected #2794

Closed
Naatan opened this issue May 25, 2013 · 4 comments
Closed

$http requests are sometimes queued and not triggered as expected #2794

Naatan opened this issue May 25, 2013 · 4 comments

Comments

@Naatan
Copy link

Naatan commented May 25, 2013

I have a $http.post with very normal looking parameters:

http://pastebin.com/VhDX5CuG

However the actual request seems to just be queued and isn't processed until I actually make another $http.get request. I can force it to be processed by calling $scope.$apply() but that doesn't seem right.

This is on 1.1.5.

@mokesmokes
Copy link

Numerous reports of this since 1.1.4, if you're doing your $http or $resource requests outside Angular context.
#2431, #2371, #2438, and probably more reports

@Naatan
Copy link
Author

Naatan commented May 25, 2013

I've written a simple small API library which performs the requests using the Angular $http object, but all of these calls are actually triggered by $scope methods, so in theory it would be within Angular's context. Also it works just fine on .get() requests, which use the exact same logic apart from the method being different.

@ricogallo
Copy link

@Naatan perhaps just before your second request you actually called (not directly) a $scope.$apply(), causing the model changes of your first get() to be noticed by angular?

@pkozlowski-opensource
Copy link
Member

@Naatan This is a side-effect of promise-based request interceptors introduced in 1.1.4. Now request interceptors are promise-based and AngularJS promises are only resolved within $digest cycle. As from 1.1.4 you need to trigger $http / $resource requests from AngularJS $digest loop.

In your particular case you need to wrap a call into $scope.$apply since you are probably triggering this call outside of the "AngularJS world".

See those 2 comments in #2431 for additional info:
#2431 (comment)
#2431 (comment)

Please reopen with a reproduce scenario (plunker) if you need further help on this one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants