diff --git a/admin/src/pages/HomePage.tsx b/admin/src/pages/HomePage.tsx index 0ea1a26d4..f07c52f28 100644 --- a/admin/src/pages/HomePage.tsx +++ b/admin/src/pages/HomePage.tsx @@ -100,7 +100,15 @@ export const HomePage = () => { pluginsSocket!.on('results:search', (data: { results: PluginDef[] }) => { - setPlugins(data.results) + if (Array.isArray(data.results) && data.results.length === 0) { + setPlugins(data.results) + } else { + useStore.getState().setToastState({ + open: true, + title: "Error retrieving plugins", + success: false + }) + } }) diff --git a/src/node/server.ts b/src/node/server.ts index df6d21ffb..f96db3ab1 100755 --- a/src/node/server.ts +++ b/src/node/server.ts @@ -27,6 +27,7 @@ import {ErrorCaused} from "./types/ErrorCaused"; import log4js from 'log4js'; import pkg from '../package.json'; import {checkForMigration} from "../static/js/pluginfw/installer"; +import axios from "axios"; const settings = require('./utils/Settings'); @@ -37,6 +38,28 @@ if (settings.dumpOnUncleanExit) { wtfnode = require('wtfnode'); } + +const addProxyToAxios = (url: URL) => { + axios.defaults.proxy = { + host: url.hostname, + port: Number(url.port), + protocol: url.protocol, + } +} + +if(process.env['http_proxy']) { + console.log("Using proxy: " + process.env['http_proxy']) + addProxyToAxios(new URL(process.env['http_proxy'])); +} + + +if (process.env['https_proxy']) { + console.log("Using proxy: " + process.env['https_proxy']) + addProxyToAxios(new URL(process.env['https_proxy'])); +} + + + /* * early check for version compatibility before calling * any modules that require newer versions of NodeJS diff --git a/src/node/utils/UpdateCheck.ts b/src/node/utils/UpdateCheck.ts index f4c10182a..534c5c640 100644 --- a/src/node/utils/UpdateCheck.ts +++ b/src/node/utils/UpdateCheck.ts @@ -1,7 +1,7 @@ 'use strict'; const semver = require('semver'); const settings = require('./Settings'); -const axios = require('axios'); +import axios from 'axios'; const headers = { 'User-Agent': 'Etherpad/' + settings.getEpVersion(), } @@ -17,7 +17,7 @@ let lastLoadingTime: number | null = null; const loadEtherpadInformations = () => { if (lastLoadingTime !== null && Date.now() - lastLoadingTime < updateInterval) { - return Promise.resolve(infos); + return infos; } return axios.get('https://static.etherpad.org/info.json', {headers: headers}) @@ -29,10 +29,10 @@ const loadEtherpadInformations = () => { } lastLoadingTime = Date.now(); - return await Promise.resolve(infos); + return infos; }) .catch(async (err: Error) => { - return await Promise.reject(err); + throw err; }); } @@ -43,15 +43,15 @@ exports.getLatestVersion = () => { }; exports.needsUpdate = async (cb?: Function) => { - await loadEtherpadInformations() - .then((info:Infos) => { - if (semver.gt(info.latestVersion, settings.getEpVersion())) { + try { + const info = await loadEtherpadInformations() + if (semver.gt(info!.latestVersion, settings.getEpVersion())) { if (cb) return cb(true); } - }).catch((err: Error) => { + } catch (err) { console.error(`Can not perform Etherpad update check: ${err}`); if (cb) return cb(false); - }); + } }; exports.check = () => {