forked from cardstack/boxel
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmatrix-js-sdk@31.0.0.patch
56 lines (56 loc) · 2.04 KB
/
matrix-js-sdk@31.0.0.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
diff --git a/lib/crypto/index.js b/lib/crypto/index.js
index b965c8c5bd8b6eb939c2f449a82e22fd83996369..be9560d26d73e671f84104c9c465ba50dc4a4f82 100644
--- a/lib/crypto/index.js
+++ b/lib/crypto/index.js
@@ -1901,10 +1901,14 @@ class Crypto extends _typedEventEmitter.TypedEventEmitter {
}
const res = await this.baseApis.uploadKeysRequest(requestBody);
if (fallbackJson) {
- this.fallbackCleanup = setTimeout(() => {
+ let timer = setTimeout(() => {
delete this.fallbackCleanup;
this.olmDevice.forgetOldFallbackKey();
}, 60 * 60 * 1000);
+ if (typeof timer.unref === "function") {
+ timer.unref();
+ }
+ this.fallbackCleanup = timer;
}
await this.olmDevice.markKeysAsPublished();
return res;
diff --git a/lib/http-api/utils.js b/lib/http-api/utils.js
index 9115598fd769bad15ed23293a68d617d5dbf21a5..95c28e59d8414dbc0837f5c85c98dd96a80446c8 100644
--- a/lib/http-api/utils.js
+++ b/lib/http-api/utils.js
@@ -30,9 +30,12 @@ limitations under the License.
// Ponyfill for https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout
function timeoutSignal(ms) {
const controller = new AbortController();
- setTimeout(() => {
+ let timer = setTimeout(() => {
controller.abort();
}, ms);
+ if (typeof timer.unref === 'function') {
+ timer.unref();
+ }
return controller.signal;
}
function anySignal(signals) {
diff --git a/lib/sync.js b/lib/sync.js
index f59265e1089ce832c0be8a23aa19813c2d4738cc..e9b70f2b75a89bb561fc420f03b5106a55f34e09 100644
--- a/lib/sync.js
+++ b/lib/sync.js
@@ -747,6 +747,13 @@ class SyncApi {
nextSyncToken: data.next_batch,
catchingUp: this.catchingUp
};
+
+ if (syncToken === data.next_batch) {
+ // there are no updates and we are just idle--wait before
+ // continuing so that idle syncs don't DDoS the server
+ await new Promise(r => setTimeout(r, 1000));
+ }
+
if (this.syncOpts.crypto) {
// tell the crypto module we're about to process a sync
// response