Skip to content

Native Bindings override issue #981

@vitaly-t

Description

@vitaly-t

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 pg via Native Bindings
  • one that uses pg via 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions