appstore: bump timeout to 60s instead of 30s

this timeout is hit on some servers (which have some networking
issue). unfortunately, this triggers a bug in superagent -
https://github.com/ladjs/superagent/issues/1801
This commit is contained in:
Girish Ramakrishnan
2024-04-23 11:41:49 +02:00
parent 9064375e25
commit 3787f90283

View File

@@ -99,7 +99,7 @@ async function login(email, password, totpToken) {
const [error, response] = await safe(superagent.post(`${await getApiServerOrigin()}/api/v1/login`)
.send({ email, password, totpToken })
.timeout(30 * 1000)
.timeout(60 * 1000)
.ok(() => true));
if (error) throw new BoxError(BoxError.NETWORK_ERROR, error.message);
@@ -116,7 +116,7 @@ async function registerUser(email, password) {
const [error, response] = await safe(superagent.post(`${await getApiServerOrigin()}/api/v1/register_user`)
.send({ email, password, utmSource: 'cloudron-dashboard' })
.timeout(30 * 1000)
.timeout(60 * 1000)
.ok(() => true));
if (error) throw new BoxError(BoxError.NETWORK_ERROR, error.message);
@@ -130,7 +130,7 @@ async function getSubscription() {
const [error, response] = await safe(superagent.get(`${await getApiServerOrigin()}/api/v1/subscription`)
.query({ accessToken: token })
.timeout(30 * 1000)
.timeout(60 * 1000)
.ok(() => true));
if (error) throw new BoxError(BoxError.NETWORK_ERROR, error.message);
@@ -161,7 +161,7 @@ async function purchaseApp(data) {
const [error, response] = await safe(superagent.post(`${await getApiServerOrigin()}/api/v1/cloudronapps`)
.send(data)
.query({ accessToken: token })
.timeout(30 * 1000)
.timeout(60 * 1000)
.ok(() => true));
if (error) throw new BoxError(BoxError.NETWORK_ERROR, error.message);
@@ -184,7 +184,7 @@ async function unpurchaseApp(appId, data) {
let [error, response] = await safe(superagent.get(url)
.query({ accessToken: token })
.timeout(30 * 1000)
.timeout(60 * 1000)
.ok(() => true));
if (error) throw new BoxError(BoxError.NETWORK_ERROR, error.message);
@@ -195,7 +195,7 @@ async function unpurchaseApp(appId, data) {
[error, response] = await safe(superagent.del(url)
.send(data)
.query({ accessToken: token })
.timeout(30 * 1000)
.timeout(60 * 1000)
.ok(() => true));
if (error) throw new BoxError(BoxError.NETWORK_ERROR, error.message);
@@ -217,7 +217,7 @@ async function getBoxUpdate(options) {
const [error, response] = await safe(superagent.get(`${await getApiServerOrigin()}/api/v1/boxupdate`)
.query(query)
.timeout(30 * 1000)
.timeout(60 * 1000)
.ok(() => true));
if (error) throw new BoxError(BoxError.NETWORK_ERROR, error.message);
@@ -260,7 +260,7 @@ async function getAppUpdate(app, options) {
const [error, response] = await safe(superagent.get(`${await getApiServerOrigin()}/api/v1/appupdate`)
.query(query)
.timeout(30 * 1000)
.timeout(60 * 1000)
.ok(() => true));
if (error) throw new BoxError(BoxError.NETWORK_ERROR, error);
@@ -292,7 +292,7 @@ async function registerCloudron(data) {
const [error, response] = await safe(superagent.post(`${await getApiServerOrigin()}/api/v1/register_cloudron`)
.send({ domain, setupToken, accessToken, version, existingApps })
.timeout(30 * 1000)
.timeout(60 * 1000)
.ok(() => true));
if (error) throw new BoxError(BoxError.NETWORK_ERROR, error.message);
@@ -328,7 +328,7 @@ async function updateCloudron(data) {
const [error, response] = await safe(superagent.post(`${await getApiServerOrigin()}/api/v1/update_cloudron`)
.query(query)
.send({ domain })
.timeout(30 * 1000)
.timeout(60 * 1000)
.ok(() => true));
if (error) throw new BoxError(BoxError.NETWORK_ERROR, error);
@@ -384,7 +384,7 @@ async function createTicket(info, auditSource) {
const request = superagent.post(`${await getApiServerOrigin()}/api/v1/ticket`)
.query({ accessToken: token })
.timeout(30 * 1000)
.timeout(60 * 1000)
.ok(() => true);
// either send as JSON through body or as multipart, depending on attachments
@@ -421,7 +421,7 @@ async function downloadManifest(appStoreId, manifest) {
debug(`downloading manifest from ${url}`);
const [error, response] = await safe(superagent.get(url).timeout(30 * 1000).ok(() => true));
const [error, response] = await safe(superagent.get(url).timeout(60 * 1000).ok(() => true));
if (error) throw new BoxError(BoxError.EXTERNAL_ERROR, 'Network error downloading manifest:' + error.message);
@@ -438,7 +438,7 @@ async function getApps() {
const [error, response] = await safe(superagent.get(`${await getApiServerOrigin()}/api/v1/apps`)
.query({ accessToken: token, boxVersion: constants.VERSION, unstable: true })
.timeout(30 * 1000)
.timeout(60 * 1000)
.ok(() => true));
if (error) throw new BoxError(BoxError.NETWORK_ERROR, error.message);
@@ -461,7 +461,7 @@ async function getAppVersion(appId, version) {
const [error, response] = await safe(superagent.get(url)
.query({ accessToken: token })
.timeout(30 * 1000)
.timeout(60 * 1000)
.ok(() => true));
if (error) throw new BoxError(BoxError.NETWORK_ERROR, error.message);
@@ -484,7 +484,7 @@ async function downloadIcon(appStoreId, version) {
return await promiseRetry({ times: 10, interval: 5000, debug }, async function () {
const [networkError, response] = await safe(superagent.get(iconUrl)
.buffer(true)
.timeout(30 * 1000)
.timeout(60 * 1000)
.ok(() => true));
if (networkError) throw new BoxError(BoxError.NETWORK_ERROR, `Network error downloading icon : ${networkError.message}`);