-
- Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
The way Native Bindings currently work, is by overriding the library's global settings:
module.exports.__defineGetter__("native", function () { delete module.exports.native; module.exports.native = new PG(require('./native')); return module.exports.native; });As a result, it creates a conflict when you try using two third-party libraries -
- one that uses
pgvia Native Bindings - one that uses
pgvia JavaScript bindings
Just as one library activates Native Bindings, it becomes global, due to Node.js module sharing principle, so it overrides this setting for libraries that do not support Native Bindings.
How to test it
Install pg-native, and declare:
var pg1 = require('pg'); var pg2 = require('pg').native;Just as pg2 is initialized, any call into pg1 for connect or query goes into the layer for the Native Bindings, thus breaking any module that supports only JavaScript bindings.
Thoughts
I don't know yet how difficult it would be to fix this, or even whether it is possible to make Native Bindings work in parallel with JavaScript Bindings within the same process, without running into conflicts. Any thoughts are welcome!