-
Type: Bug
-
Resolution: Fixed
-
Priority: Blocker - P1
-
Affects Version/s: 3.6.3
-
Component/s: None
-
Empty show more show less
Problem Description
On a windows machine without, for example, snappy in the require path, mongodb ends up in an infinite loop when trying to optionally require snappy.
This is beacuse a bug in the package require_optional
The search starts in the given path, if the file isn't found it continues with the parent folder, and so on in a loop. The stop criterias for the loop are
- The file is found
- The current path equals '/'
It never matches the second critera on a Windows machine, where paths starts with the drive letter, for example 'C:\'
See bug for description:
https://github.com/christkv/require_optional/issues/11
A PR for this has been available since Nov 9 2018 without being merge
https://github.com/christkv/require_optional/pull/8
I think it's safe to say the package is dead!
The infinite loop happens directly in the require('mongodb') call.
Possible fix
Switch to the package require-optional: https://www.npmjs.com/package/require-optional
The mongodb package uses require_optional with only one parameter. This is functionally equal to calling require-optional with only one parameter, so a search and replace for:
require('require_optional')
to
require('require-optional')
is enough.
I've successfully monkey patched my system's node_modules/mongodb this way.
- related to
-
NODE-1749 Please make require_optional for kerberos go away...
- Closed