Skip to content

Commit

Permalink
DataSync: Configurable message timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
mpscholten committed Nov 17, 2023
1 parent d59a65d commit 583e665
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/IHP/DataSync/ihp-datasync.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
}
}
});
Expand Down

0 comments on commit 583e665

Please sign in to comment.