diff --git a/backend/package.json b/backend/package.json index a75c80b2..a4b7f63d 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.22.25", + "version": "2.22.26", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/restful/settings.js b/backend/src/restful/settings.js index a7ef0836..61022ae1 100644 --- a/backend/src/restful/settings.js +++ b/backend/src/restful/settings.js @@ -67,6 +67,7 @@ async function updateSettings(req, res) { }; [ 'defaultTimeout', + 'githubApiTimeout', 'cacheThreshold', 'resourceCacheTtl', 'headersCacheTtl', @@ -117,6 +118,7 @@ export async function updateAvatar() { syncPlatform, githubProxy, githubApiUrl, + githubApiTimeout, } = settings; if (username) { if (syncPlatform === 'gitlab') { @@ -130,6 +132,7 @@ export async function updateAvatar() { 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36', }, + timeout: githubApiTimeout || 10000, }) .then((resp) => JSON.parse(resp.body)); settings.avatarUrl = data[0]['avatar_url'].replace( @@ -157,6 +160,7 @@ export async function updateAvatar() { 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36', }, + timeout: githubApiTimeout || 10000, }) .then((resp) => JSON.parse(resp.body)); settings.avatarUrl = data['avatar_url']; diff --git a/backend/src/utils/gist.js b/backend/src/utils/gist.js index 9a7cd4e5..3fdc580b 100644 --- a/backend/src/utils/gist.js +++ b/backend/src/utils/gist.js @@ -36,10 +36,11 @@ export default class Gist { const { isStash, isLoon, isShadowRocket, isQX } = ENV(); const { defaultProxy, - defaultTimeout: timeout, + githubApiTimeout, githubProxy, githubApiUrl, } = $.read(SETTINGS_KEY); + const githubApiRequestTimeout = githubApiTimeout || 10000; const githubGistBaseURL = getGithubGistBaseURL({ githubApiUrl, githubProxy, @@ -75,7 +76,7 @@ export default class Gist { ...(isLoon && proxy ? { node: proxy } : {}), ...(isQX && proxy ? { opts: { policy: proxy } } : {}), ...(proxy ? getPolicyDescriptor(proxy) : {}), - timeout: timeout || 8000, + timeout: githubApiRequestTimeout, events: { onResponse: (resp) => { @@ -125,7 +126,7 @@ export default class Gist { ...(isLoon && proxy ? { node: proxy } : {}), ...(isQX && proxy ? { opts: { policy: proxy } } : {}), ...(proxy ? getPolicyDescriptor(proxy) : {}), - timeout: timeout || 8000, + timeout: githubApiRequestTimeout, events: { onResponse: (resp) => {