Skip to content

Build your personal knowledge base with Trilium Notes

client: Remove errors in log when changing a setting

Elian Doranbd20cec2865a
diff --git a/src/public/app/services/server.js b/src/public/app/services/server.js
index b8a1d29fbf..b715a426cf 100644
--- a/src/public/app/services/server.js
+++ b/src/public/app/services/server.js
@@ -135,7 +135,11 @@ function ajax(url, method, data, headers, silentNotFound) {
});
},
error: async jqXhr => {
- if (silentNotFound && jqXhr.status === 404) {
+ if (jqXhr.status === 0) {
+ // don't report requests that are rejected by the browser, usually when the user is refreshing or going to a different page.
+ rej("rejected by browser");
+ return;
+ } else if (silentNotFound && jqXhr.status === 404) {
// report nothing
} else {
await reportError(method, url, jqXhr.status, jqXhr.responseText);
diff --git a/src/public/app/widgets/note_context_aware_widget.js b/src/public/app/widgets/note_context_aware_widget.js
index 1fb7e5de8e..1d3a98b9c3 100644
--- a/src/public/app/widgets/note_context_aware_widget.js
+++ b/src/public/app/widgets/note_context_aware_widget.js
@@ -57,7 +57,17 @@ class NoteContextAwareWidget extends BasicWidget {
async refresh() {
if (this.isEnabled()) {
this.toggleInt(true);
- await this.refreshWithNote(this.note);
+
+ try {
+ await this.refreshWithNote(this.note);
+ } catch (e) {
+ // Ignore errors when user is refreshing or navigating away.
+ if (e === "rejected by browser") {
+ return;
+ }
+
+ throw e;
+ }
}
else {
this.toggleInt(false);