1
0
Derivar 0

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

feature/long-poll-status
Daniel Perelman há 4 anos
ascendente 997d1260c8
cometimento 44402c3907

@ -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;

Carregando…
Cancelar
Guardar