diff --git a/packages/server/src/app.ts b/packages/server/src/app.ts index 044680a2c4..f0e091986e 100644 --- a/packages/server/src/app.ts +++ b/packages/server/src/app.ts @@ -251,12 +251,14 @@ async function main() { appLogger().info(`Starting server v${config().appVersion} (${env}) on port ${config().port} and PID ${process.pid}...`); - const timeDrift = await getDeviceTimeDrift(); - if (Math.abs(timeDrift) > config().maxTimeDrift) { - throw new Error(`The device time drift is ${timeDrift}ms (Max allowed: ${config().maxTimeDrift}ms) - cannot continue as it could cause data loss and conflicts on the sync clients. You may increase env var MAX_TIME_DRIFT to pass the check.`); + if (config().maxTimeDrift) { + const timeDrift = await getDeviceTimeDrift(); + if (Math.abs(timeDrift) > config().maxTimeDrift) { + throw new Error(`The device time drift is ${timeDrift}ms (Max allowed: ${config().maxTimeDrift}ms) - cannot continue as it could cause data loss and conflicts on the sync clients. You may increase env var MAX_TIME_DRIFT to pass the check.`); + } + appLogger().info(`NTP time offset: ${timeDrift}ms`); } - appLogger().info(`NTP time offset: ${timeDrift}ms`); appLogger().info('Running in Docker:', runningInDocker()); appLogger().info('Public base URL:', config().baseUrl); appLogger().info('API base URL:', config().apiBaseUrl); diff --git a/packages/server/src/env.ts b/packages/server/src/env.ts index 2076391cc8..d00135d81a 100644 --- a/packages/server/src/env.ts +++ b/packages/server/src/env.ts @@ -21,8 +21,8 @@ const defaultEnvValues: EnvVariables = { // milliseconds is normally not an issue unless many clients are modifying // the same note at the exact same time. But past a certain limit, it might // mean the server clock is incorrect and should be fixed, as that could - // result in clients generating many conflicts. - // https://github.com/laurent22/joplin/issues/5738 + // result in clients generating many conflicts. Set to 0 to disable the + // check. https://github.com/laurent22/joplin/issues/5738 MAX_TIME_DRIFT: 100,