mirror of
https://github.com/status-im/codimd.git
synced 2025-01-14 04:15:01 +00:00
feat(versionCheck): add timeout to 1s and change logger type to avoid log error to disturb user
Signed-off-by: BoHong Li <raccoon@hackmd.io>
This commit is contained in:
parent
4c7497960a
commit
b49a4e24f1
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user