🐛 Fixed EADDRINUSE error handling on NodeJS >=13 (#12591)

closes https://github.com/TryGhost/Ghost#12562

- From NodeJS v13 `error.errno` returns error code instead of a string. Because  of that use friendly "port is already in use" message did not work anymore. 
- Changed to use `error.code` which acts the same way as `error.errno` in older NodeJS versions.
This commit is contained in:
KiraLT 2021-02-16 14:26:06 +02:00 committed by GitHub
parent 66fe678cb7
commit ba1ffb7b5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,7 +82,7 @@ class GhostServer {
self.httpServer.on('error', function (error) { self.httpServer.on('error', function (error) {
let ghostError; let ghostError;
if (error.errno === 'EADDRINUSE') { if (error.code === 'EADDRINUSE') {
ghostError = new errors.GhostError({ ghostError = new errors.GhostError({
message: i18n.t('errors.httpServer.addressInUse.error'), message: i18n.t('errors.httpServer.addressInUse.error'),
context: i18n.t('errors.httpServer.addressInUse.context', {port: config.get('server').port}), context: i18n.t('errors.httpServer.addressInUse.context', {port: config.get('server').port}),