Skip to content

Commit ba291bc

Browse files
committed
updated scripts
1 parent 53ad20c commit ba291bc

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

chat-app/frontend/scripts.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ async function keepFetchingMessages() {
5454
const lastMessageTime = state.messages.at(-1)?.timestamp ?? null;
5555
const queryString = lastMessageTime ? `?since=${lastMessageTime}` : "";
5656
const url = `${state.backendURL}/messages${queryString}`;
57-
const milliseconds = 100;
57+
const pollingIntervalMS = 100;
5858
try {
59-
// fetch may remain pending up to 25 seconds
59+
// the backend is using long-polling, and will hang open for up to 25 seconds waiting for an update event before returning
6060
const rawResponse = await fetch(url);
6161
const response = await rawResponse.json();
6262
if (response.length > 0) {
@@ -66,7 +66,7 @@ async function keepFetchingMessages() {
6666
} catch (error) {
6767
console.log(`Failed on connection: ${error}`);
6868
}
69-
setTimeout(keepFetchingMessages, milliseconds);
69+
setTimeout(keepFetchingMessages, pollingIntervalMS);
7070
}
7171

7272
function messageInputReset() {

0 commit comments

Comments
 (0)