zone-eu / zone-mta

📤 Modern outbound MTA cross platform and extendable server application
European Union Public License 1.2
599 stars 96 forks source link

mongodb driver v4 update breaks zonemta #278

Closed dazoot closed 3 years ago

dazoot commented 3 years ago

I did an upgrade to 3.2.0 and the server does not start:

Sep  7 17:22:08 zmta1 zone-mta: npm ERR! code ELIFECYCLE
Sep  7 17:22:08 zmta1 zone-mta: npm ERR! errno 1
Sep  7 17:22:08 zmta1 zone-mta: npm ERR! zone-mta-template@1.0.2 start: `node index.js --config=/etc/zonemta/zonemta.toml "--max-old-space-size=512"`
Sep  7 17:22:08 zmta1 zone-mta: npm ERR! Exit status 1
Sep  7 17:22:08 zmta1 zone-mta: npm ERR!
Sep  7 17:22:08 zmta1 zone-mta: npm ERR! Failed at the zone-mta-template@1.0.2 start script.
Sep  7 17:22:08 zmta1 zone-mta: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Sep  7 17:22:08 zmta1 zone-mta:
Sep  7 17:22:08 zmta1 zone-mta: npm ERR! A complete log of this run can be found in:
Sep  7 17:22:08 zmta1 zone-mta: npm ERR!     /root/.npm/_logs/2021-09-07T14_22_08_477Z-debug.log
Sep  7 17:24:10 zmta1 zone-mta:
Sep  7 17:24:10 zmta1 zone-mta: > zone-mta-template@1.0.2 start /usr/local/zonemta
Sep  7 17:24:10 zmta1 zone-mta: > node index.js --config=/etc/zonemta/zonemta.toml "--max-old-space-size=512"
Sep  7 17:24:10 zmta1 zone-mta:
Sep  7 17:24:11 zmta1 zone-mta: /usr/local/zonemta/node_modules/whatwg-url/dist/encoding.js:2
Sep  7 17:24:11 zmta1 zone-mta: const utf8Encoder = new TextEncoder();
Sep  7 17:24:11 zmta1 zone-mta:                     ^
Sep  7 17:24:11 zmta1 zone-mta:
Sep  7 17:24:11 zmta1 zone-mta: ReferenceError: TextEncoder is not defined
Sep  7 17:24:11 zmta1 zone-mta:     at Object.<anonymous> (/usr/local/zonemta/node_modules/whatwg-url/dist/encoding.js:2:21)
Sep  7 17:24:11 zmta1 zone-mta:     at Module._compile (internal/modules/cjs/loader.js:778:30)
Sep  7 17:24:11 zmta1 zone-mta:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
Sep  7 17:24:11 zmta1 zone-mta:     at Module.load (internal/modules/cjs/loader.js:653:32)
Sep  7 17:24:11 zmta1 zone-mta:     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
Sep  7 17:24:11 zmta1 zone-mta:     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Sep  7 17:24:11 zmta1 zone-mta:     at Module.require (internal/modules/cjs/loader.js:692:17)
Sep  7 17:24:11 zmta1 zone-mta:     at require (internal/modules/cjs/helpers.js:25:18)
Sep  7 17:24:11 zmta1 zone-mta:     at Object.<anonymous> (/usr/local/zonemta/node_modules/whatwg-url/dist/url-state-machine.js:5:34)
Sep  7 17:24:11 zmta1 zone-mta:     at Module._compile (internal/modules/cjs/loader.js:778:30)
Sep  7 17:24:11 zmta1 zone-mta: npm ERR! code ELIFECYCLE
Sep  7 17:24:11 zmta1 zone-mta: npm ERR! errno 1
Sep  7 17:24:11 zmta1 zone-mta: npm ERR! zone-mta-template@1.0.2 start: `node index.js --config=/etc/zonemta/zonemta.toml "--max-old-space-size=512"`
Sep  7 17:24:11 zmta1 zone-mta: npm ERR! Exit status 1
Sep  7 17:24:11 zmta1 zone-mta: npm ERR!
Sep  7 17:24:11 zmta1 zone-mta: npm ERR! Failed at the zone-mta-template@1.0.2 start script.
Sep  7 17:24:11 zmta1 zone-mta: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Sep  7 17:24:11 zmta1 zone-mta:
louis-lau commented 3 years ago

Could this be because this project doesn't use a package-lock.json? Try removing package-lock.json and node_modules, then doing an npm install. I'm not sure what the reasoning is behind not committing package-lock, but it can lead to issues.

dazoot commented 3 years ago

package-lock.json is generated on each build.

dazoot commented 3 years ago

On node: 12.14.0 zonemta starts OK. On older node: 10.24.0 i get the error.

louis-lau commented 3 years ago

Ah alright, if you're using some kind of pipeline where this isn't a problem, ignore me haha.

dazoot commented 3 years ago

Does not seem to be directly related to mongo driver though, but some other dependencies introduced by the new driver.

andris9 commented 3 years ago

Yeah, the mongo driver needed upgrade but it does not support older Nodejs versions. I’ll update the required engine version in packge.json, current one is not correct (should be 11 not 10)

dazoot commented 3 years ago

Can we support at least node 10 ? It seems node 11 is not getting any security updates.

andris9 commented 3 years ago

mongodb v4 module is quite a large change, it is not 100% backwards compatible and going back to v3 module would mean that it only delays adopting v4 which will eventually happen anyway. From the docs they require at least 12.9, I'm not sure what's the difference exactly. Additionally at one point ZoneMTA will start requiring Node v14 because that's the version needed to provided MTA-STS support via the mailauth module.

dazoot commented 3 years ago

Fair enough. Upgrade it is :)