Skip to content

pg.native – return null if pg-native is missing #950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2016

Conversation

langpavel
Copy link
Contributor

require('pg').native will be null and report error once to stdout when pg-native is missing.

Fixes #838

`require('pg').native` will be `null` and report error once to `stdout` when `pg-native` is missing.
@langpavel
Copy link
Contributor Author

May be solution for #945 too. @janmeier what you think?

@janmeier
Copy link

It would solve the biggest part of the issue, crashing the app, but would still mean that an error message is logged to the console, without the user knowing why - "But I'm not accessing the native property directly, why do I see this message"

@langpavel
Copy link
Contributor Author

@janmeier Because something (babel in this case?) accessing native property.
Message can be removed and null returned, but this is not good solution.

Message is shown only once when native property is accessed first time.

Any suggestions welcomed!

@anthonyjspoerl
Copy link

Is there a better solution for this being worked on? I am not using pg-native and am running into this issue in CI. I would prefer this solution over having to unnecessarily configure pg-native in CI.

@langpavel
Copy link
Contributor Author

@anthonyjspoerl There is PR #952 which hide property from Babel by making property nonenumerable.
I'm not sure how tools like eslint-plugin-import cope with hidden property, so return null and report warning when property is very firstly accessed is correct way.
I can add process.env.… switch to suppress warning, but this is unnecesary by my opinion.
Best solution should be instruct tooling to not touch this property.

@brianc
Copy link
Owner

brianc commented Apr 28, 2016

Dang sorry I missed this! I've been in the weeds with other things in my life for a while, getting out now finally. 💃

I'll go through the PRs and see which ones break backwards compatibility, clump them up, merge them, and push a new major version. I consider this a backwards break since someone somewhere might be depending weirdly on it throwing an exception.

@langpavel langpavel changed the title pg.native returns null if pg-native is missing pg.native – return null if pg-native is missing Apr 28, 2016
@vitaly-t
Copy link
Contributor

vitaly-t commented May 1, 2016

All libraries that rely on node-postgres to detect and throw when pg-native isn't found would have to be modified, if we allow this change.

At the moment, the exception thrown is the only pointer that pg-native is missing as a dependency.

In all, this would be a breaking change (not that I'm against it) ;)

@gaastonsr
Copy link

Bump!

Using knex.js and Node 6 and receiving error.

Advice for a patch in the mean time?

@brianc brianc merged commit ad2ffce into brianc:master Jun 7, 2016
@langpavel
Copy link
Contributor Author

I think this is good choice. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants