mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
connectivity fixes
This commit is contained in:
parent
705a817b12
commit
79fa61fa33
6 changed files with 116 additions and 90 deletions
|
@ -117,18 +117,31 @@
|
|||
return fetch(request.url, fetchRequest);
|
||||
}
|
||||
|
||||
return fetchWithTimeout(request.url, fetchRequest, request.timeout);
|
||||
}
|
||||
|
||||
function fetchWithTimeout(url, options, timeoutMs) {
|
||||
|
||||
logger.log('fetchWithTimeout: timeoutMs: ' + timeoutMs + ', url: ' + url);
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
var timeout = setTimeout(reject, request.timeout);
|
||||
var timeout = setTimeout(reject, timeoutMs);
|
||||
|
||||
fetch(request.url, fetchRequest).then(function (response) {
|
||||
fetch(url, options).then(function (response) {
|
||||
clearTimeout(timeout);
|
||||
|
||||
logger.log('fetchWithTimeout: succeeded connecting to url: ' + url);
|
||||
|
||||
resolve(response);
|
||||
}, function (error) {
|
||||
|
||||
clearTimeout(timeout);
|
||||
|
||||
logger.log('fetchWithTimeout: timed out connecting to url: ' + url);
|
||||
|
||||
throw error;
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -155,10 +168,12 @@
|
|||
|
||||
request.headers = request.headers || {};
|
||||
|
||||
logger.log('Requesting url without automatic networking: ' + request.url);
|
||||
logger.log('ConnectionManager requesting url: ' + request.url);
|
||||
|
||||
return getFetchPromise(request).then(function (response) {
|
||||
|
||||
logger.log('ConnectionManager response status: ' + response.status + ', url: ' + request.url);
|
||||
|
||||
if (response.status < 400) {
|
||||
|
||||
if (request.dataType == 'json' || request.headers.accept == 'application/json') {
|
||||
|
@ -170,8 +185,10 @@
|
|||
return Promise.reject(response);
|
||||
}
|
||||
|
||||
}, function (error) {
|
||||
throw error;
|
||||
}, function (err) {
|
||||
|
||||
logger.log('ConnectionManager request failed to url: ' + request.url);
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue