Skip to content

Conversation

@jmgasper
Copy link
Contributor

@jmgasper jmgasper commented Dec 8, 2025

No description provided.

@jmgasper jmgasper merged commit 7027456 into master Dec 8, 2025
6 checks passed
} else {
logger.error(`Failed to delete MailChimp subscriber from list ${list.id}: ${err.message}`)
throw err
const deletionResults = await Promise.allSettled(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
Using Promise.allSettled is a good choice for handling multiple promises where you want to continue processing even if some fail. However, be cautious about the potential for unhandled promise rejections if any of the axios.post calls throw an error that is not a 404. Consider logging all errors within the catch block to ensure no silent failures.

})
)

const failedDeletion = deletionResults.find((result) => result.status === 'rejected')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
The current implementation only throws the first error encountered in failedDeletion. If multiple deletions fail, you might miss other errors. Consider logging all errors or aggregating them to provide a complete picture of what went wrong.

logger.error(`MailChimp deletion failed for ${member.email}: ${err.message}`)
}
// Kick off MailChimp deletion without blocking the API response.
;(async () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ readability]
The use of an immediately invoked function expression (IIFE) to perform an asynchronous operation is unconventional and may lead to confusion. Consider using a named async function or a promise-based approach to improve readability and maintainability.

// Kick off MailChimp deletion without blocking the API response.
;(async () => {
try {
await mailchimp.deleteSubscriber(member.email)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The member.email variable is used within the asynchronous function, which may lead to unexpected behavior if member is modified elsewhere before the function executes. Consider capturing member.email in a local variable before the IIFE to ensure the correct value is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants