Skip to content

Commit

Permalink
Fixed knex connection pool errors when scheduling a posts
Browse files Browse the repository at this point in the history
no issue

- A subquery in mege service that creates email record wasn't using 'options' object needed to track transactions
  • Loading branch information
naz committed Nov 26, 2019
1 parent 4790e64 commit 9ff5fec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/server/api/canary/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ module.exports = {
let postEmail = model.relations.email;

if (!postEmail) {
const email = await mega.addEmail(model.toJSON());
const email = await mega.addEmail(model.toJSON(), frame.options);
model.set('email', email);
} else if (postEmail && postEmail.get('status') === 'failed') {
const email = await mega.retryFailedEmail(postEmail);
Expand Down
4 changes: 2 additions & 2 deletions core/server/services/mega/mega.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const sendTestEmail = async (postModel, emails) => {
*
* @param {object} post JSON object
*/
const addEmail = async (post) => {
const addEmail = async (post, options) => {
const {members} = await membersService.api.members.list(Object.assign({filter: 'subscribed:true'}, {limit: 'all'}));
const {emailTmpl, emails} = getEmailData(post, members);

Expand All @@ -77,7 +77,7 @@ const addEmail = async (post) => {
html: emailTmpl.html,
plaintext: emailTmpl.plaintext,
submitted_at: moment().toDate()
});
}, {transacting: options.transacting});
} else {
return existing;
}
Expand Down

0 comments on commit 9ff5fec

Please sign in to comment.