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.

Ability to force *not* loading native client

See original GitHub issue

node-postres supports setting NODE_PG_FORCE_NATIVE to force the loading of the native client, but there’s no way to force it to not load the native client:

if (typeof process.env.NODE_PG_FORCE_NATIVE !== 'undefined') {
  module.exports = new PG(require('./native'))
} else {
  module.exports = new PG(Client)

  // lazy require native module...the native module may not have installed
  module.exports.__defineGetter__('native', function () {
    delete module.exports.native
    var native = null
    try {
      native = new PG(require('./native'))
    } catch (err) {
      if (err.code !== 'MODULE_NOT_FOUND') {
        throw err
      }
      /* eslint-disable no-console */
      console.error(err.message)
      /* eslint-enable no-console */
    }
    module.exports.native = native
    return native
  })
}

This can cause spurious warnings about pg-native module not found. See https://github.com/sequelize/sequelize/issues/3781 for an example caused by cloning node-postgres objects.

Potential solution: support a NODE_PG_NO_LOAD_NATIVE environment variable. Setting this would cause the native getter to not be defined. Setting both NODE_PG_NO_LOAD_NATIVE and NODE_PG_FORCE_NATIVE could throw an error.

I’m happy to throw together a PR if there’s support for something like this.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:13
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
charmandercommented, Jul 11, 2020

As of pg 8.0, native isn’t enumerable. (Cloning modules still sounds like a bug in sequelize or in the use of sequelize, though.)

1reaction
gabegorelickcommented, Oct 25, 2019

Why is this seemingly magical getter necessary? Couldn’t it be simply a .getNative() instead?

That would be a much bigger breaking change. I think simply making native non-enumerable, as proposed in #1992, solves all of the issues that I am aware of without breaking all but the most contrived usages.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Frequently Asked Questions - Chrome Developers
This document answers some frequently asked questions about Native Client (NaCl) and Portable Native Client (PNaCl, pronounced “pinnacle”).
Read more >
How to fix 8 common remote desktop connection problems
First, try to establish a session from a client that has been able to successfully connect in the past. The goal is to...
Read more >
Can't run "npm install expo-cli --global"
open start > search for cmd > right click on cmd and click run as administrator > Now npm i -g expo-cli this...
Read more >
How to troubleshoot non-browser apps that can't sign in to ...
The keyboard on the client computer keyboard is working correctly, and the user name and the password were entered correctly. Non-browser app authentication ......
Read more >
Native Client Launchers - Ignition User Manual 7.9
The Ignition Gateway contains downloadable native executables that can launch Clients directly without invoking Java Web Start.
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