mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 14:46:04 +02:00
Don't retry 404's
This commit is contained in:
@@ -352,6 +352,7 @@ speechSynthesis.getVoices();
|
|||||||
};
|
};
|
||||||
|
|
||||||
API.pendingGetRequests = new Map();
|
API.pendingGetRequests = new Map();
|
||||||
|
API.failedGetRequests = new Map();
|
||||||
|
|
||||||
API.call = function (endpoint, options) {
|
API.call = function (endpoint, options) {
|
||||||
var init = {
|
var init = {
|
||||||
@@ -361,6 +362,14 @@ speechSynthesis.getVoices();
|
|||||||
};
|
};
|
||||||
var { params } = init;
|
var { params } = init;
|
||||||
if (init.method === 'GET') {
|
if (init.method === 'GET') {
|
||||||
|
// don't retry recent 404
|
||||||
|
if (this.failedGetRequests.has(endpoint)) {
|
||||||
|
var lastRun = this.failedGetRequests.get(endpoint);
|
||||||
|
if (lastRun >= Date.now() - 900000) { //15mins
|
||||||
|
throw new Error(`Bailing request due to past 404, ${endpoint}`);
|
||||||
|
}
|
||||||
|
this.failedGetRequests.delete(endpoint);
|
||||||
|
}
|
||||||
// transform body to url
|
// transform body to url
|
||||||
if (params === Object(params)) {
|
if (params === Object(params)) {
|
||||||
var url = new URL(init.url);
|
var url = new URL(init.url);
|
||||||
@@ -426,8 +435,12 @@ speechSynthesis.getVoices();
|
|||||||
message: 'Avatar private or deleted',
|
message: 'Avatar private or deleted',
|
||||||
type: 'error'
|
type: 'error'
|
||||||
});
|
});
|
||||||
|
$app.avatarDialog.visable = false;
|
||||||
throw new Error('404: Can\'t find avatarǃ');
|
throw new Error('404: Can\'t find avatarǃ');
|
||||||
}
|
}
|
||||||
|
if ((init.method === 'GET') && (status === 404)) {
|
||||||
|
this.failedGetRequests.set(endpoint, Date.now());
|
||||||
|
}
|
||||||
if (data.error === Object(data.error)) {
|
if (data.error === Object(data.error)) {
|
||||||
this.$throw(
|
this.$throw(
|
||||||
data.error.status_code || status,
|
data.error.status_code || status,
|
||||||
|
|||||||
Reference in New Issue
Block a user