-
Notifications
You must be signed in to change notification settings - Fork 679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix when config is undefined. #50
Conversation
Hi there -- sorry for the late response. Why would config ever not be defined? Can you show me how to reproduce the error before I merge this in? |
Have also encountered this; seems to occur if the response is a 500 error on certain requests.. |
@marcelaraujo your interceptor is breaking the angular requirements for an interceptor which is why there's no config. From the docs:
So specifically, your interceptor's response looks like this: myApp.factory('handlerInterceptorFactory', [function() {
return {
'response': function(response) {
return null; // <-- this is not returning the config object
return response || $q.when(response);
}
}
}]); Happy to investigate further if you can correct the example fiddle and still replicate the error. |
@chieffancypants, I agree that but sometimes when the server returns no response, I catch this error . |
I've experiencing the same issue when buffering HTTP requests and aborting them. For example, using this library https://github.com/witoldsz/angular-http-auth throws the same error above. Thanks, |
@Incisive I'm using the same library and have never seen this. When you abort the request, are you rejecting the promise or returning null? |
Thanks again,
|
It seems my issue was caused by passing the wrong argument into the 'loginCancelled' method and I no longer have the above issues. I've updated my above comment with the correct use. Sorry for the confusion, |
In each case this error has been the result of an implementation issue somewhere else, and unrelated to the loading bar. I'm going to close for now, but please feel free to re-open if anyone is able to reproduce while adhering to specs. |
@chieffancypants here is updated version: http://jsfiddle.net/Q9Bx6/9/ |
@just-boris that fiddle includes an improperly written interceptor. Please read the comments above, as I specifically show the line that breaks everything |
Sorry, wrong version. Here an example without interceptor: http://jsfiddle.net/Q9Bx6/10/ |
This is a pretty strange situation, but this is actually a bug within Angular. When following the call stack you can see it's not returning a response object in the format required for an interceptor. It's also throwing it's own errors as it can't access the local resource. {
code: 19,
message: "Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file://resource.txt/'.",
name: "NetworkError",
stack: "Error: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file://resource.txt/'.↵ at Error (native)↵ at https://code.angularjs.org/1.3.13/angular.js:9827:11↵ at sendReq (https://code.angularjs.org/1.3.13/angular.js:9628:9)↵ at serverRequest (https://code.angularjs.org/1.3.13/angular.js:9344:16)↵ at processQueue (https://code.angularjs.org/1.3.13/angular.js:13189:27)↵ at https://code.angularjs.org/1.3.13/angular.js:13205:27↵ at Scope.$eval (https://code.angularjs.org/1.3.13/angular.js:14401:28)↵ at Scope.$digest (https://code.angularjs.org/1.3.13/angular.js:14217:31)↵ at Scope.$apply (https://code.angularjs.org/1.3.13/angular.js:14506:24)↵ at HTMLButtonElement.<anonymous> (https://code.angularjs.org/1.3.13/angular.js:21440:23)",
__proto__: DOMException
} |
@chieffancypants why are think that interceptor always gets response? In the angular docs responseError argument named a I thought about to report issue into angular, but decided, that it's correct behavior, because there is no actually a response object, request throw an exception synchronously |
I don't think this is properly solved yet. We're getting "Broken interceptor detected: Config object not supplied in rejection:" even though the loading bar is the one and only interceptor we have. I have not been able to reproduce it in a fiddle, because I think it depends on the reply we get from our API (which is locked down inside a VPN) |
Turned out I had a TypeError. That's why there was no config property on the rejection object. I think you should consider handling Error objects as well. I found this comment in an article about interceptors: "And, we may not have access to the config - the rejection may be an error object." from http://www.bennadel.com/blog/2777-monitoring-http-activity-with-http-interceptors-in-angularjs.htm |
I am also getting the same error when I try to upload a file using ng-file-upload |
@chieffancypants, I won't give you more reasons to fix this behavior. A lot of developers and apps use your module and they have the same issue too. Please, do me a favor, fix it. Make everyone happy. |
got it fixed by adding a config object to response |
There's nothing to fix. I added in a detector, which will actually help developers way more than just ignoring it completely. |
I think that detector might actually do more harm than good in some cases right now. I got the "Broken interceptor detected: Config object not supplied in rejection" message even when your interceptor was the only one loaded. Perhaps you should check |
@Tobbe I see, I think you're right. It appears angular will catch the error, but it's not super clear what it does with it. Either way, the documentation shows that response errors do not require a config object, so at the very minimum this should be fixed |
Looking forward to the fix 👍 |
"Either way, the documentation shows that response errors do not require a config object, so at the very minimum this should be fixed" Finally! You've been having dozens of complaints, issues and PRs and you keep pushing back. I myself have the same issue and can't find the origin. The loading bar is the one and only interceptor and I keep getting Sentry notifications on that same line ( |
Just to show where this scenario can occur without any other interceptors defined. I had a case where a configured URL was not specified resulting in a null url parameter being passed to $http.post. The result is an infinite loading bar. See example here: |
I'm also looking forward to the fix! |
I had have the same issue.
I have fixed it just by returning |
My SOLUTION for "Broken interceptor detected" message with 'angular-loading-bar' module. I found that problem is caused by wrong order of Angular module dependencies.
I hope, it helps you. |
In my case, I was not sending back from server proper response. In php I had to json_encode my response body. Just to say sometimes we focus on front end while error is on back end ;) |
I was struggling in this problem did some refactor on my interceptors but when I checked what @rcollette wrote I just found the problem. I was getting an undefined url :( |
I got this error while parsing an invalid, unbalanced JSON resource. I missed a '}' in the property file at the server in my JHipster project). |
I have this request:
and the error |
@alex88 you may try to add a interceptor that
|
There is plenty of information about this above, and elsewhere. Locking thread. |
Sometimes, the config is not provided in cache function. So, I fixed it.
TypeError: Cannot read property 'config' of undefined