mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-27 16:54:04 +00:00
Merge pull request #2495 from minhhoangvn/fix/update-service-name-grpc
Bug fix: gRPC check throws errors when response data size > 50 chars
This commit is contained in:
commit
41a9f2ff8a
3 changed files with 28 additions and 18 deletions
|
@ -548,7 +548,7 @@ class Monitor extends BeanModel {
|
||||||
log.debug("monitor:", `gRPC response: ${JSON.stringify(response)}`);
|
log.debug("monitor:", `gRPC response: ${JSON.stringify(response)}`);
|
||||||
let responseData = response.data;
|
let responseData = response.data;
|
||||||
if (responseData.length > 50) {
|
if (responseData.length > 50) {
|
||||||
responseData = response.substring(0, 47) + "...";
|
responseData = responseData.toString().substring(0, 47) + "...";
|
||||||
}
|
}
|
||||||
if (response.code !== 1) {
|
if (response.code !== 1) {
|
||||||
bean.status = DOWN;
|
bean.status = DOWN;
|
||||||
|
|
|
@ -714,6 +714,7 @@ let needSetup = false;
|
||||||
bean.authDomain = monitor.authDomain;
|
bean.authDomain = monitor.authDomain;
|
||||||
bean.grpcUrl = monitor.grpcUrl;
|
bean.grpcUrl = monitor.grpcUrl;
|
||||||
bean.grpcProtobuf = monitor.grpcProtobuf;
|
bean.grpcProtobuf = monitor.grpcProtobuf;
|
||||||
|
bean.grpcServiceName = monitor.grpcServiceName;
|
||||||
bean.grpcMethod = monitor.grpcMethod;
|
bean.grpcMethod = monitor.grpcMethod;
|
||||||
bean.grpcBody = monitor.grpcBody;
|
bean.grpcBody = monitor.grpcBody;
|
||||||
bean.grpcMetadata = monitor.grpcMetadata;
|
bean.grpcMetadata = monitor.grpcMetadata;
|
||||||
|
|
|
@ -778,22 +778,31 @@ module.exports.grpcQuery = async (options) => {
|
||||||
cb);
|
cb);
|
||||||
}, false, false);
|
}, false, false);
|
||||||
return new Promise((resolve, _) => {
|
return new Promise((resolve, _) => {
|
||||||
return grpcService[`${grpcMethod}`](JSON.parse(grpcBody), function (err, response) {
|
try {
|
||||||
const responseData = JSON.stringify(response);
|
return grpcService[`${grpcMethod}`](JSON.parse(grpcBody), function (err, response) {
|
||||||
if (err) {
|
const responseData = JSON.stringify(response);
|
||||||
return resolve({
|
if (err) {
|
||||||
code: err.code,
|
return resolve({
|
||||||
errorMessage: err.details,
|
code: err.code,
|
||||||
data: ""
|
errorMessage: err.details,
|
||||||
});
|
data: ""
|
||||||
} else {
|
});
|
||||||
log.debug("monitor:", `gRPC response: ${response}`);
|
} else {
|
||||||
return resolve({
|
log.debug("monitor:", `gRPC response: ${JSON.stringify(response)}`);
|
||||||
code: 1,
|
return resolve({
|
||||||
errorMessage: "",
|
code: 1,
|
||||||
data: responseData
|
errorMessage: "",
|
||||||
});
|
data: responseData
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
return resolve({
|
||||||
|
code: -1,
|
||||||
|
errorMessage: `Error ${err}. Please review your gRPC configuration option. The service name must not include package name value, and the method name must follow camelCase format`,
|
||||||
|
data: ""
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue