mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Return an error for a canceled request.
Allow the datasource to decide how to handle a canceled request.
This commit is contained in:
@@ -120,21 +120,15 @@ function (angular, _, coreModule, config) {
|
||||
|
||||
return $http(options).then(null, function(err) {
|
||||
if (err.status === HTTP_REQUEST_ABORTED) {
|
||||
// Need to return the right data structure so it has no effect on
|
||||
// iterating over returned data in datasource.ts#115
|
||||
// TODO: Hitting another refresh cancels the "loading" animation on
|
||||
// panes. Figure out how to keep it going.
|
||||
return {
|
||||
data: {
|
||||
data: {
|
||||
result: []
|
||||
}
|
||||
}
|
||||
};
|
||||
// TODO: Hitting refresh before the original request returns cancels
|
||||
// the "loading" animation on the panes, but it should continue to be
|
||||
// visible.
|
||||
err.statusText = "request aborted";
|
||||
return err;
|
||||
}
|
||||
|
||||
// handle unauthorized for backend requests
|
||||
if (requestIsLocal && firstAttempt && err.status === 401) {
|
||||
if (requestIsLocal && firstAttempt && err.status === 401) {
|
||||
return self.loginPing().then(function() {
|
||||
options.retry = 1;
|
||||
canceler.resolve();
|
||||
|
||||
@@ -58,6 +58,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
|
||||
return escapedValues.join('|');
|
||||
};
|
||||
|
||||
var HTTP_REQUEST_ABORTED = -1;
|
||||
// Called once per panel (graph)
|
||||
this.query = function(options) {
|
||||
var self = this;
|
||||
@@ -107,6 +108,9 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
|
||||
var result = [];
|
||||
|
||||
_.each(allResponse, function(response, index) {
|
||||
if (response.status === HTTP_REQUEST_ABORTED) {
|
||||
return;
|
||||
}
|
||||
if (response.status === 'error') {
|
||||
self.lastErrors.query = response.error;
|
||||
throw response.error;
|
||||
|
||||
Reference in New Issue
Block a user