Skip to content

Commit 651ed9a

Browse files
authored
Fix net::ERR_INSUFFICIENT_RESOURCES errors on HTTP2 introduced in 5.4.1 (#415)
1 parent bb03899 commit 651ed9a

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

src/persistence/BaseMCWSPersistenceProvider.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,25 @@ export default class BaseMCWSPersistenceProvider {
5959
* @returns {Promise.<NamespaceDefinition[]>} persistenceNamespaces
6060
*/
6161
async getPersistenceNamespaces() {
62-
// get root namespaces, get contained namespaces.
63-
if (!this.persistenceNamespaces) {
64-
const rootNamespaces = await this.getRootNamespaces();
65-
const allContainedNamespaces = await this.getAllContainedNamespaces(rootNamespaces);
62+
// Return cached result if available
63+
if (this.persistenceNamespaces) {
64+
return this.persistenceNamespaces;
65+
}
66+
67+
// If initialization is in progress, wait for it
68+
if (!this.persistenceNamespacesPromise) {
69+
this.persistenceNamespacesPromise = (async () => {
70+
const rootNamespaces = await this.getRootNamespaces();
71+
const allContainedNamespaces = await this.getAllContainedNamespaces(rootNamespaces);
72+
73+
this.persistenceNamespaces = [...rootNamespaces, ...allContainedNamespaces];
74+
delete this.persistenceNamespacesPromise;
6675

67-
this.persistenceNamespaces = [...rootNamespaces, ...allContainedNamespaces];
76+
return this.persistenceNamespaces;
77+
})();
6878
}
6979

70-
return this.persistenceNamespaces;
80+
return this.persistenceNamespacesPromise;
7181
}
7282

7383
/**

src/services/mcws/MCWSClient.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ class MCWSClient {
6060
delete options.params;
6161
}
6262

63-
// Keepalive
64-
options.keepalive = true;
65-
6663
try {
6764
response = await fetch(url, options);
6865
} catch (error) {

0 commit comments

Comments
 (0)