From 14c0c065261653299ad5a03b119d97f8fa1acd88 Mon Sep 17 00:00:00 2001 From: Yury Molodov Date: Thu, 25 Apr 2024 12:52:13 +0200 Subject: [PATCH] vmui: improve error message for server response issues (#6177) Updates error messages for better clarity and guidance on server response issues. (cherry picked from commit 57b7d16259df728766e9269afa05757bdb325761) --- app/vmui/packages/vmui/src/hooks/useFetchQuery.ts | 12 ++++++++++-- docs/CHANGELOG.md | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/vmui/packages/vmui/src/hooks/useFetchQuery.ts b/app/vmui/packages/vmui/src/hooks/useFetchQuery.ts index 345958fe7..d700c7a4e 100644 --- a/app/vmui/packages/vmui/src/hooks/useFetchQuery.ts +++ b/app/vmui/packages/vmui/src/hooks/useFetchQuery.ts @@ -153,9 +153,17 @@ export const useFetchQuery = ({ setTraces(tempTraces); setIsHistogram(prev => totalLength ? isHistogramResult : prev); } catch (e) { - if (e instanceof Error && e.name !== "AbortError") { - setError(`${e.name}: ${e.message}`); + const error = e as Error; + if (error.name === "AbortError") { + // Aborts are expected, don't show an error for them. + return; } + const helperText = "Please check your serverURL settings and confirm server availability."; + let text = `Error executing query: ${error.message}. ${helperText}`; + if (error.message === "Unexpected end of JSON input") { + text += "\nAdditionally, this error can occur if the server response is too large to process. Apply more specific filters to reduce the data volume."; + } + setError(text); } setIsLoading(false); }; diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 2a5103416..03d041086 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -42,6 +42,7 @@ See also [LTS releases](https://docs.victoriametrics.com/lts-releases/). * FEATURE: [vmui](https://docs.victoriametrics.com/#vmui): optimize auto-suggestion performance for metric names when the database contains big number of unique time series. * FEATURE: [vmui](https://docs.victoriametrics.com/#vmui): in the Select component, user-entered values are now preserved on blur if they match options in the list. * FEATURE: [vmui](https://docs.victoriametrics.com/#vmui): auto-suggestion triggers at any cursor position in the query input. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5864). +* FEATURE: [vmui](https://docs.victoriametrics.com/#vmui): update error messages on the Query page for enhanced clarity. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/6177). * BUGFIX: [downsampling](https://docs.victoriametrics.com/#downsampling): skip unnecessary index lookups if downsampling wasn't set for ENT versions of VictoriaMetrics. Before, users of VictoriaMetrics ENT could have experience elevated CPU usage even if no downsampling was configured. The issue was introduced in [v1.100.0](https://docs.victoriametrics.com/changelog/#v11000). * BUGFIX: [downsampling](https://docs.victoriametrics.com/#downsampling): properly populate downsampling metadata for data parts created by VictoriaMetrics ENT versions lower than v1.100.0. The bug could trigger the downsampling actions for parts that were downsampled already. This bug doesn't have any negative effect apart from spending extra CPU resources on the repeated downsampling. The issue was introduced in [v1.100.0](https://docs.victoriametrics.com/changelog/#v11000).