0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

🐛 Fixed site setup hanging when mail isn't configured

closes https://github.com/TryGhost/Team/issues/3176

We were waiting for the welcome email to send before responding to the
client that setup is complete, this was causing the client to hang when
running `ghost install local` as mail isn't configured by default.
This commit is contained in:
Fabien 'egg' O'Carroll 2023-05-11 11:58:27 -04:00 committed by GitHub
parent d86ac17e31
commit 13a18711d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View file

@ -3,6 +3,7 @@ const api = require('./index');
const config = require('../../../shared/config');
const tpl = require('@tryghost/tpl');
const errors = require('@tryghost/errors');
const logging = require('@tryghost/logging');
const web = require('../../web');
const models = require('../../models');
const auth = require('../../services/auth');
@ -70,8 +71,11 @@ module.exports = {
return auth.setup.doSettings(data, api.settings);
})
.then((user) => {
return auth.setup.sendWelcomeEmail(user.get('email'), api.mail)
.then(() => user);
auth.setup.sendWelcomeEmail(user.get('email'), api.mail)
.catch((err) => {
logging.error(err);
});
return user;
});
}
},

View file

@ -7,6 +7,20 @@ const {tokens} = require('@tryghost/security');
const models = require('../../../../core/server/models');
const settingsCache = require('../../../../core/shared/settings-cache');
async function waitForEmailSent(emailMockReceiver, number = 1) {
let sentEmailCount = 0;
while (sentEmailCount === 0) {
try {
emailMockReceiver.assertSentEmailCount(number);
sentEmailCount = number;
} catch (e) {
await new Promise((resolve) => {
setTimeout(resolve, 100);
});
}
}
}
describe('Authentication API', function () {
let emailMockReceiver;
let agent;
@ -71,6 +85,8 @@ describe('Authentication API', function () {
etag: anyEtag
});
await waitForEmailSent(emailMockReceiver);
// Test our side effects
emailMockReceiver.matchHTMLSnapshot();
emailMockReceiver.matchPlaintextSnapshot();
@ -208,6 +224,8 @@ describe('Authentication API', function () {
etag: anyEtag
});
await waitForEmailSent(emailMockReceiver);
// Test our side effects
emailMockReceiver.matchHTMLSnapshot();
emailMockReceiver.matchPlaintextSnapshot();