Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
The error probably is a MongoServerError, not MongoError, see https://github.com/mongodb/node-mongodb-native/blob/HEAD/etc/notes/errors.md
You encountered probably the only case in the driver this happens lol. When constructing the client, the driver uses a class called ConnectionString from another mongodb maintained library (mongo connection string url). In this class, the url is parsed and if the url is malformed, the MongoParseError is thrown. But this is a third party library, so it doesn't have access to the errors defined in the driver. To get around this, it defines a fake MongoParseError here. Because this class isn't the same error class as the driver's error class and it only extends Error, the instanceof check breaks.