Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: return 200 for Bounce collection VersionError #472

Merged
merged 4 commits into from
Oct 15, 2020

Conversation

mantariksh
Copy link
Contributor

@mantariksh mantariksh commented Oct 15, 2020

Problem

Email notifications arrive at our /emailnotifications endpoint asynchronously, and processing them involves retrieving documents from the Bounce collection. This means that multiple server instances sometimes attempt to access and modify the same Bounce document concurrently, resulting in Mongoose throwing VersionErrors. These errors are caught and HTTP 400 is returned, sometimes resulting in false HTTP 400 alarms.

Solution

Check if the error is a VersionError, and return 200 if it is. The idea here is that we accept the risk of VersionErrors as a limitation of our system, and return an OK response since the error is on our end.

Other improvements

Tests for the Bounce and Verification controllers were updated with hardcoded numbers for HTTP status codes instead of using the http-status-codes package.

Copy link
Contributor

@liangyuanruo liangyuanruo left a comment

Choose a reason for hiding this comment

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

lgtm, but i thought we liked http status code enums

@liangyuanruo liangyuanruo merged commit f988396 into develop Oct 15, 2020
@liangyuanruo liangyuanruo deleted the feat/bounce-saves branch October 15, 2020 12:32
@tshuli tshuli mentioned this pull request Oct 20, 2020
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.

None yet

2 participants