check that the server is running at least NodeJS v16.14.2

pull/1/head
ansuz 3 years ago
parent 6061e8869c
commit f34a60665f

@ -27,6 +27,25 @@ var deriveSandboxOrigin = function (unsafe, port) {
return url.origin; return url.origin;
}; };
var isRecentVersion = function () {
var V = process.version;
if (typeof(V) !== 'string') { return false; }
var parts = V.replace(/^v/, '').split('.').map(Number);
if (parts.length < 3) { return false; }
if (!parts.every(n => typeof(n) === 'number' && !isNaN(n))) {
return false;
}
if (parts[0] < 16) { return false; }
if (parts[0] > 16) { return true; }
// v16
if (parts[1] < 14) { return false; }
if (parts[1] > 14) { return true; }
if (parts[2] >= 2) { return true; }
return false;
};
module.exports.create = function (config) { module.exports.create = function (config) {
var httpUnsafeOrigin = canonicalizeOrigin(config.httpUnsafeOrigin); var httpUnsafeOrigin = canonicalizeOrigin(config.httpUnsafeOrigin);
@ -53,6 +72,8 @@ module.exports.create = function (config) {
NO_SANDBOX: NO_SANDBOX, NO_SANDBOX: NO_SANDBOX,
httpSafePort: httpSafePort, httpSafePort: httpSafePort,
shouldUpdateNode: !isRecentVersion(),
version: Package.version, version: Package.version,
installMethod: config.installMethod || undefined, installMethod: config.installMethod || undefined,

@ -236,6 +236,7 @@ var serveConfig = makeRouteCache(function (host) {
httpSafeOrigin: Env.httpSafeOrigin, httpSafeOrigin: Env.httpSafeOrigin,
disableEmbedding: Env.disableEmbedding, disableEmbedding: Env.disableEmbedding,
fileHost: Env.fileHost, fileHost: Env.fileHost,
shouldUpdateNode: Env.shouldUpdateNode || undefined,
}, null, '\t'), }, null, '\t'),
'});' '});'
].join(';\n') ].join(';\n')
@ -325,6 +326,13 @@ nThen(function (w) {
Env.Log = _log; Env.Log = _log;
config.log = _log; config.log = _log;
if (Env.shouldUpdateNode) {
Env.Log.warn("NODEJS_OLD_VERSION", {
message: `The CryptPad development team recommends using at least NodeJS v16.14.2`,
currentVersion: process.version,
});
}
if (Env.OFFLINE_MODE) { return; } if (Env.OFFLINE_MODE) { return; }
if (Env.websocketPath) { return; } if (Env.websocketPath) { return; }

@ -1310,6 +1310,21 @@ define([
}); });
}); });
assert(function (cb, msg) {
msg.appendChild(h('span', [
"The CryptPad development team recommends running at least NodeJS ",
code("v16.14.2"),
". Which can be installed and updated via ",
h('a', {
href: 'https://github.com/nvm-sh/nvm',
rel: 'noopener noreferer',
target: '_blank',
}, 'NVM'),
'.',
]));
cb(!ApiConfig.shouldUpdateNode);
});
var serverToken; var serverToken;
Tools.common_xhr('/', function (xhr) { Tools.common_xhr('/', function (xhr) {
serverToken = xhr.getResponseHeader('server'); serverToken = xhr.getResponseHeader('server');

Loading…
Cancel
Save