From 583e6656731bcfcd60a99641baa7eb73319d8b2a Mon Sep 17 00:00:00 2001 From: Marc Scholten Date: Fri, 17 Nov 2023 10:41:43 -0800 Subject: [PATCH] DataSync: Configurable message timeout --- lib/IHP/DataSync/ihp-datasync.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/IHP/DataSync/ihp-datasync.js b/lib/IHP/DataSync/ihp-datasync.js index 9fbe3dca2..4800c31f7 100644 --- a/lib/IHP/DataSync/ihp-datasync.js +++ b/lib/IHP/DataSync/ihp-datasync.js @@ -54,6 +54,9 @@ class DataSyncController { // When doing optimistic inserts, we want to optimistically set the `createdAt` field, if the record will have such a field after insert // For that we need to keep track of all tables that have a `createdAt` field. this.optimisticCreatedNeedsCreatedAtField = new Set(); + + // The websocket times out after not receiving a reply for 5 seconds + this.messageTimeout = 5000; } async startConnection() { @@ -174,7 +177,7 @@ class DataSyncController { this.connection.send(JSON.stringify(payload)); if (!this.pendingRequestTimeout) { - this.pendingRequestTimeout = setTimeout(this.onPendingRequestTimeout.bind(this), 5000); + this.pendingRequestTimeout = setTimeout(this.onPendingRequestTimeout.bind(this), this.messageTimeout); } } });