Unverified Commit b49a4e24 authored by BoHong Li's avatar BoHong Li
Browse files

feat(versionCheck): add timeout to 1s and change logger type to avoid log error to disturb user


Signed-off-by: default avatarBoHong Li <raccoon@hackmd.io>
parent 4c749796
......@@ -30,11 +30,12 @@ async function checkVersion (ctx) {
const { statusCode, body: data } = await rp({
url: `${VERSION_CHECK_ENDPOINT}?v=${config.version}`,
method: 'GET',
json: true
json: true,
timeout: 1000
})
if (statusCode !== 200 || data.status === 'error') {
logger.error('Version check failed.')
logger.warn('Version check failed.')
return
}
......@@ -46,12 +47,12 @@ async function checkVersion (ctx) {
if (!data.latest) {
const { version, link } = data.versionItem
logger.warn(`Your CodiMD version is out of date! The latest version is ${version}. Please see what's new on ${link}.`)
logger.info(`Your CodiMD version is out of date! The latest version is ${version}. Please see what's new on ${link}.`)
}
} catch (err) {
// ignore and skip version check
logger.error('Version check failed.')
logger.error(err)
logger.warn('Version check failed.')
logger.warn(err)
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment