Browse Source

Cancel long-polling for status from client side after 50 seconds.

feature/long-poll-status
Daniel Perelman 2 years ago
parent
commit
44402c3907
1 changed files with 11 additions and 1 deletions
  1. +11
    -1
      fear_tracker/templates/game.html

+ 11
- 1
fear_tracker/templates/game.html View File

@@ -362,11 +362,21 @@

function checkStatus() {
if(activeRequests.size != 0) return;
// From https://stackoverflow.com/a/50101022

const abort = new AbortController();
const signal = abort.signal;

// 50 second timeout:
const timeoutId = setTimeout(() => abort.abort(), 50000);

fetch(new Request("{% url 'status' access_code=access_code %}"
+ (statusObj.hash != ""
? statusObj.hash + "/"
: "")))
: "")),
{signal})
.then(response => {
clearTimeout(timeoutId);
if(response.status === 304) {
// TODO Just skip the next step?
return statusObj;


Loading…
Cancel
Save