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

Mongo driver 4 rc fix duplicate error #95

Open
wants to merge 6 commits into
base: mongo-driver-4-rc
Choose a base branch
from

Conversation

aljones15
Copy link
Contributor

@aljones15 aljones15 commented Oct 28, 2022

  1. Fixes the Duplicate check
  2. Adds a check for MongoError.

@aljones15 aljones15 self-assigned this Oct 28, 2022
@codecov-commenter
Copy link

codecov-commenter commented Oct 28, 2022

Codecov Report

Merging #95 (325828f) into mongo-driver-4-rc (5b28284) will increase coverage by 1.42%.
The diff coverage is 100.00%.

@@                  Coverage Diff                  @@
##           mongo-driver-4-rc      #95      +/-   ##
=====================================================
+ Coverage              87.08%   88.50%   +1.42%     
=====================================================
  Files                      8        8              
  Lines                    813      870      +57     
=====================================================
+ Hits                     708      770      +62     
+ Misses                   105      100       -5     
Impacted Files Coverage Δ
lib/exceptions.js 100.00% <100.00%> (ø)
lib/helpers.js 97.10% <100.00%> (+2.06%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@aljones15 aljones15 marked this pull request as ready for review October 31, 2022 19:39
MDBE_WRITE_CONCERN_ERROR,
WRITE_CONCERN_ERROR,
WRITE_ERROR
]);
Copy link
Member

Choose a reason for hiding this comment

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

-1 to adding all these, we should only add what we need (and we haven't needed any of these) -- otherwise it's just more to maintain and test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point. There might be an automated way of adding these though. I'll look into it and if not cut them down to something more manageable. I also think not all of these errors are root errors, many of them are the cause of a MongoError I believe.

Copy link
Contributor Author

@aljones15 aljones15 Nov 1, 2022

Choose a reason for hiding this comment

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

Ok so I looked into this today and basically here is the problem: MongoError seems to be nothing more than an abstract class, then MongoError in turn has about 5-6 errors that derive from it, then those 5-6 errors in turn throw the errors listed above and are base classes for a panoply of different errors. So we can pretty safely remove MongoError, but the issue is the driver throws most of the other errors so we probably do need to ensure we know their names.

Copy link
Contributor Author

@aljones15 aljones15 Nov 1, 2022

Choose a reason for hiding this comment

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

ok so I trimmed this down to just the two errors that are kind of sort of thrown by the driver that are not MongoErrors. Then I added a new function assertMongoError here: 43ab9b0
and here:
94bf529

This method should work as the node mongo driver is now written using typescript so there are a lot of Abstract base classes and inheritance based type checking structures that ultimately result in 3 cases: either you get a MongoError, a WriteError or WriteConcernError. For the most part you only get MongoError, but documents can contain WriteError and MongoError can contain both WriteError or WriteConcernError so there might be edge cases were we're asserting on the cause of a MongoError or on the writeErrors property of MongoError or document.

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.

3 participants