Skip to content

Commit 9d3d526

Browse files
committed
httpmsg: one poll at a time
1 parent 7673b39 commit 9d3d526

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/services/httpmsg/html.toit

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ html-page device/devices.Device docsUrl/string custom-actions/Map -> string:
8989
console.error('Error:', error);
9090
});
9191
}
92+
let fetching = false;
9293
function poll() {
94+
if (fetching) return;
95+
fetching = true;
9396
fetch('/poll')
9497
.then(response => response.text())
9598
.then(text => {
@@ -117,6 +120,9 @@ html-page device/devices.Device docsUrl/string custom-actions/Map -> string:
117120
})
118121
.catch((error) => {
119122
console.error('Error:', error);
123+
})
124+
.finally(() => {
125+
fetching = false;
120126
});
121127
}
122128
setInterval(poll, 2000);

0 commit comments

Comments
 (0)