diff --git a/CHANGELOG.md b/CHANGELOG.md index b6787e0409..fef4b7e8b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased - feat(bind): Added option to bind to specific http address +- fix(migration): Unleash should not start if migration fails. ## 3.0.2 - fix(package): Update unleash-frontend to version 3.0.1 diff --git a/lib/server-impl.js b/lib/server-impl.js index bb15b81d2b..167eef71f9 100644 --- a/lib/server-impl.js +++ b/lib/server-impl.js @@ -38,12 +38,17 @@ function createApp(options) { }); } -function start(opts) { +async function start(opts) { const options = createOptions(opts); - return migrator({ databaseUrl: options.databaseUrl }) - .catch(err => logger.error('failed to migrate db', err)) - .then(() => createApp(options)); + try { + await migrator({ databaseUrl: options.databaseUrl }); + } catch (err) { + logger.error('Failed to migrate db', err); + throw err; + } + + return createApp(options); } module.exports = {