Open holm opened 6 years ago
(I'm working with @holm on this)
Just did a bit more debugging. It's easily reproducible with a stock Ubuntu 16.04 and Node 10.4.1 using the binaries from nodejs.org.
Then this simple script
var Client = require('pg-native')
var client = new Client()
client.connectSync('postgres://user:password@rds-instance.eu-west-1.rds.amazonaws.com/postgres?sslmode=require')
fails with this error
/app/node_modules/libpq/index.js:28
throw err;
^
Error: could not create SSL context: library has no ciphers
at PQ.connectSync (/app/node_modules/libpq/index.js:26:15)
at module.exports.Client.connectSync (/app/node_modules/pg-native/index.js:50:11)
at Object.<anonymous> (/app/flo.js:4:9)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
at startup (internal/bootstrap/node.js:238:19)
It works on Ubuntu 18.04, where libpq is linked against a newer openssl version whereas on 16.04 it's using 1.0.2g (and node 10 is bundling 1.1.0h).
Not quite sure though why/if the openssl upgrade in Node10 would affect pg-native? Isn't everything going directly to libpq and that handles the SSL connection itself?
I’m pretty sure libpq and Node can’t use different OpenSSL versions. See #70 for the same issue in reverse.
I just tried to upgrade to node-10 on my project which also uses heroku. We got the same error when trying to run db-migrate (which uses pg-natice on ssl-connections) on our production-database. Using node 9.x works fine.
Is it possible to get this working on heroku with node 10?
With node 10.13.0 I get this:
error /project/node_modules/libpq: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /project/node_modules/libpq
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@10.13.0 | darwin | x64
gyp info spawn /usr/bin/python
gyp info spawn args [ '/usr/local/Cellar/node@10/10.13.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/project/node_modules/libpq/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/Cellar/node@10/10.13.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/johndoe/.node-gyp/10.13.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/johndoe/.node-gyp/10.13.0',
gyp info spawn args '-Dnode_gyp_dir=/usr/local/Cellar/node@10/10.13.0/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/johndoe/.node-gyp/10.13.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/project/node_modules/libpq',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/addon/src/connection.o
In file included from ../src/connection.cc:1:
In file included from ../src/addon.h:4:
In file included from ../node_modules/nan/nan.h:192:
../node_modules/nan/nan_maybe_43_inl.h:112:15: error: no member named 'ForceSet' in 'v8::Object'
return obj->ForceSet(isolate->GetCurrentContext(), key, value, attribs);
~~~ ^
In file included from ../src/connection.cc:1:
In file included from ../src/addon.h:4:
In file included from ../node_modules/nan/nan.h:198:
In file included from ../node_modules/nan/nan_new.h:189:
../node_modules/nan/nan_implementation_12_inl.h:337:28: warning: 'New' is deprecated [-Wdeprecated-declarations]
return v8::StringObject::New(value).As<v8::StringObject>();
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8.h:5052:3: note: 'New' has been explicitly marked deprecated here
V8_DEPRECATED("Use Isolate* version",
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8config.h:327:29: note: expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
In file included from ../src/connection.cc:1:
In file included from ../src/addon.h:4:
../node_modules/nan/nan.h:834:18: warning: 'MakeCallback' is deprecated: Use MakeCallback(..., async_context) [-Wdeprecated-declarations]
return node::MakeCallback(
^
/Users/johndoe/.node-gyp/10.13.0/include/node/node.h:175:1: note: 'MakeCallback' has been explicitly marked deprecated here
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
^
/Users/johndoe/.node-gyp/10.13.0/include/node/node.h:91:20: note: expanded from macro 'NODE_DEPRECATED'
__attribute__((deprecated(message))) declarator
^
In file included from ../src/connection.cc:1:
In file included from ../src/addon.h:4:
../node_modules/nan/nan.h:849:18: warning: 'MakeCallback' is deprecated: Use MakeCallback(..., async_context) [-Wdeprecated-declarations]
return node::MakeCallback(
^
/Users/johndoe/.node-gyp/10.13.0/include/node/node.h:168:1: note: 'MakeCallback' has been explicitly marked deprecated here
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
^
/Users/johndoe/.node-gyp/10.13.0/include/node/node.h:91:20: note: expanded from macro 'NODE_DEPRECATED'
__attribute__((deprecated(message))) declarator
^
In file included from ../src/connection.cc:1:
In file included from ../src/addon.h:4:
../node_modules/nan/nan.h:864:18: warning: 'MakeCallback' is deprecated: Use MakeCallback(..., async_context) [-Wdeprecated-declarations]
return node::MakeCallback(
^
/Users/johndoe/.node-gyp/10.13.0/include/node/node.h:161:1: note: 'MakeCallback' has been explicitly marked deprecated here
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
^
/Users/johndoe/.node-gyp/10.13.0/include/node/node.h:91:20: note: expanded from macro 'NODE_DEPRECATED'
__attribute__((deprecated(message))) declarator
^
In file included from ../src/connection.cc:1:
In file included from ../src/addon.h:4:
../node_modules/nan/nan.h:911:44: warning: 'ToString' is deprecated [-Wdeprecated-declarations]
v8::Local<v8::String> string = from->ToString();
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8.h:2454:10: note: 'ToString' has been explicitly marked deprecated here
inline V8_DEPRECATED("Use maybe version", Local<String> ToString() const);
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8config.h:327:29: note: expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
In file included from ../src/connection.cc:1:
In file included from ../src/addon.h:4:
../node_modules/nan/nan.h:921:27: warning: 'WriteUtf8' is deprecated [-Wdeprecated-declarations]
length_ = string->WriteUtf8(str_, static_cast<int>(len), 0, flags);
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8.h:2658:3: note: 'WriteUtf8' has been explicitly marked deprecated here
V8_DEPRECATED("Use Isolate* version",
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8config.h:327:29: note: expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
In file included from ../src/connection.cc:1:
In file included from ../src/addon.h:4:
../node_modules/nan/nan.h:1473:31: warning: 'MakeCallback' is deprecated: Use MakeCallback(..., async_context) [-Wdeprecated-declarations]
return scope.Escape(node::MakeCallback(
^
/Users/johndoe/.node-gyp/10.13.0/include/node/node.h:175:1: note: 'MakeCallback' has been explicitly marked deprecated here
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
^
/Users/johndoe/.node-gyp/10.13.0/include/node/node.h:91:20: note: expanded from macro 'NODE_DEPRECATED'
__attribute__((deprecated(message))) declarator
^
../src/connection.cc:204:41: warning: 'Int32Value' is deprecated [-Wdeprecated-declarations]
char* colName = PQfname(res, info[0]->Int32Value());
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8.h:2478:3: note: 'Int32Value' has been explicitly marked deprecated here
V8_DEPRECATED("Use maybe version", int32_t Int32Value() const);
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8config.h:327:29: note: expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
../src/connection.cc:219:39: warning: 'Int32Value' is deprecated [-Wdeprecated-declarations]
int colName = PQftype(res, info[0]->Int32Value());
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8.h:2478:3: note: 'Int32Value' has been explicitly marked deprecated here
V8_DEPRECATED("Use maybe version", int32_t Int32Value() const);
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8config.h:327:29: note: expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
../src/connection.cc:230:28: warning: 'Int32Value' is deprecated [-Wdeprecated-declarations]
int rowNumber = info[0]->Int32Value();
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8.h:2478:3: note: 'Int32Value' has been explicitly marked deprecated here
V8_DEPRECATED("Use maybe version", int32_t Int32Value() const);
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8config.h:327:29: note: expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
../src/connection.cc:231:28: warning: 'Int32Value' is deprecated [-Wdeprecated-declarations]
int colNumber = info[1]->Int32Value();
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8.h:2478:3: note: 'Int32Value' has been explicitly marked deprecated here
V8_DEPRECATED("Use maybe version", int32_t Int32Value() const);
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8config.h:327:29: note: expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
../src/connection.cc:248:28: warning: 'Int32Value' is deprecated [-Wdeprecated-declarations]
int rowNumber = info[0]->Int32Value();
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8.h:2478:3: note: 'Int32Value' has been explicitly marked deprecated here
V8_DEPRECATED("Use maybe version", int32_t Int32Value() const);
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8config.h:327:29: note: expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
../src/connection.cc:249:28: warning: 'Int32Value' is deprecated [-Wdeprecated-declarations]
int colNumber = info[1]->Int32Value();
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8.h:2478:3: note: 'Int32Value' has been explicitly marked deprecated here
V8_DEPRECATED("Use maybe version", int32_t Int32Value() const);
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8config.h:327:29: note: expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
../src/connection.cc:754:18: warning: 'Utf8Length' is deprecated [-Wdeprecated-declarations]
int len = str->Utf8Length() + 1;
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8.h:2587:3: note: 'Utf8Length' has been explicitly marked deprecated here
V8_DEPRECATED("Use Isolate version instead", int Utf8Length() const);
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8config.h:327:29: note: expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
../src/connection.cc:756:8: warning: 'WriteUtf8' is deprecated [-Wdeprecated-declarations]
str->WriteUtf8(buffer, len);
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8.h:2658:3: note: 'WriteUtf8' has been explicitly marked deprecated here
V8_DEPRECATED("Use Isolate* version",
^
/Users/johndoe/.node-gyp/10.13.0/include/node/v8config.h:327:29: note: expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
15 warnings and 1 error generated.
make: *** [Release/obj.target/addon/src/connection.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/Cellar/node@10/10.13.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Darwin 18.0.0
gyp ERR! command "/usr/local/Cellar/node@10/10.13.0/bin/node" "/usr/local/Cellar/node@10/10.13.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /project/node_modules/libpq
I'm having the same problem as @tapz on Fedora with Node 10
etting same problem on various versions of Node from 8 to 10.16 except 10.15.3 where the error is could not create SSL context: library has no ciphers. All this on AWS Elastic Beanstalk.
The solution was to simply use pg instead of pg-native.
etting same problem on various versions of Node from 8 to 10.16 except 10.15.3 where the error is could not create SSL context: library has no ciphers. All this on AWS Elastic Beanstalk.
The solution was to simply use pg instead of pg-native.
hello. Could you help me? I used pg-native as option for pg-promise on node 8 it was working fine. But on node from 10.16 it is not working. I updaten openssl on my computer to 1.1.1 but it not working. What you meaned about use pg instead pg-native? How to decide my problem?
I was able to get this working for Heroku and Node v12.13.1 by adding libpq
v1.8.9 to my package.json (to allow for the latest fix) and then updating my Heroku app Stack to heroku-18
(https://devcenter.heroku.com/changelog-items/1681) since that stack has OpenSSL v1.1.1 😄 👍
We have been using pg-native for years now without issues. We are now upgrading to Node 10 and are running into problems. Using just
pg
works without issues, but withpg-native
we see this error when trying to connect to a db using ssl:could not create SSL context: library has no ciphers
It then fails to connect as we require SSL.
Versions node: 10.4.1. pg-native: 3.0.0 libpq: 1.8.8 openssl: 1.1.0g
Any ideas what could be wrong?