BSONError != BSONError

Why does this snippet output ‘false’?

import { ObjectId } from "mongodb";
import { BSONError } from "bson";

try {
    ObjectId.createFromHexString('s');
} catch (err) {
    console.log(err instanceof BSONError);
}

Hi Lukas!

The BSONError raised by the createFromHexString function is instantiated from an object declared in node_modules/mongodb/lib/bson.js.

The BSONError object that you import is declared in node_modules/bson/lib/bson.mjs.

To verify this, run the following code:

const { ObjectId } = require("mongodb");
const { BSONError } = require ("mongodb/lib/bson");

try {
    ObjectId.createFromHexString('s');
} catch (err) {
    console.log(err instanceof BSONError);
}

@Lukas_N, can you confirm Stanimira_Vlaeva’s finding.

A couple of us are really interested to know the result of the experimentation that was proposed.