question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Native Bindings override issue

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
brianccommented, Apr 8, 2016

Offf yeah that’s just a nasty bug. I’m putting together a PR for it right now. ❤️

0reactions
vitaly-tcommented, Apr 9, 2016

Fixed in version 4.5.3.

My testing confirms that it is working now, at least on the surface - connections are now correct. It would take running the two bindings side-by-side to see if there is any issue remains. Time will tell 😉

@brianc Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot override native keybindings #8541 - atom/atom - GitHub
If I e.g. want to add this key binding it won't work: 'atom-text-editor': 'ctrl-d': 'editor:duplicate-lines' Just because ctrl-d is set as native!
Read more >
jersey 2.0 - HK2 What is the proper way to override bindings of ...
I come from the guice world and am looking for a way to do something similar to the Modules. override provided by Guice....
Read more >
no suitable method found to override in a Xamarin bindings ...
I was having problems when calling a method from this binding library and i thought that was caused by some binding error but...
Read more >
Creating a Xamarin Android binding library - Writing the binding
Invalidating means that a big bunch of classes and method have been removed. Therefore I always treat those warnings as errors to fix...
Read more >
can we override default method in java - Lena's Italian Restaurant
A model in which the messages read from an inbound topic, ... If native encoding is enabled on the output binding (user has...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found