Giter Club home page Giter Club logo

node-pg-libpq's People

Contributors

jacott avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

langpavel pgps

node-pg-libpq's Issues

Fails to compile with VS2015

Hi

I get compilation errors when trying to install the package.
I am on Windows 10, x64, node v0.12.4, node-gyp v3.2.1 and VS 2015.

pg_config exists on the PATH and is valid

X:\Playground\node-postgresql\pg-libpq-test>pg_config --libdir
X:/Frameworks/postgresql-9.5.0-1-windows-x64-binaries/pgsql/lib

but npm install fails

X:\Playground\node-postgresql\pg-libpq-test>npm install pg-libpq --save

> [email protected] install X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq
> node-gyp rebuild


X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq>if not defined npm_config_node_gyp (node "X:\Frameworks\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  exec.cc
  pg_libpq.cc
x:\playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq\src\pg_libpq.h(55): warning C4005: 'THIS': macro redefinition (compiling source file ..\src\pg_libpq.cc) [X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq\build\pg_libpq.vcxproj]
  C:\Program Files (x86)\Windows Kits\8.1\Include\um\combaseapi.h(195): note: see previous definition of 'THIS' (compiling source file ..\src\pg_libpq.cc)
..\src\pg_libpq.cc(96): error C2065: 'uint': undeclared identifier [X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq\build\pg_libpq.vcxproj]
..\src\pg_libpq.cc(96): error C2146: syntax error: missing ';' before identifier 'len' [X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq\build\pg_libpq.vcxproj]
..\src\pg_libpq.cc(96): error C2065: 'len': undeclared identifier [X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq\build\pg_libpq.vcxproj]
..\src\pg_libpq.cc(97): error C2065: 'len': undeclared identifier [X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq\build\pg_libpq.vcxproj]
..\src\pg_libpq.cc(111): warning C4244: 'argument': conversion from 'double' to 'int', possible loss of data [X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq\build\pg_libpq.vcxproj]
..\src\pg_libpq.cc(307): error C2131: expression did not evaluate to a constant [X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq\build\pg_libpq.vcxproj]
  ..\src\pg_libpq.cc(307): note: failure was caused by non-constant arguments or reference to a non-constant symbol
  ..\src\pg_libpq.cc(307): note: see usage of 'cCount'
..\src\pg_libpq.cc(309): error C3863: array type 'v8::Local<v8::String> [cCount]' is not assignable [X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq\build\pg_libpq.vcxproj]
..\src\pg_libpq.cc(318): error C2664: 'bool v8::Object::Set(uint32_t,v8::Handle<v8::Value>)': cannot convert argument 1 from 'v8::Local<v8::String> [cCount]' to 'v8::Handle<v8::Value>' [X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq\build\pg_libpq.vcxproj]
  ..\src\pg_libpq.cc(318): note: No constructor could take the source type, or constructor overload resolution was ambiguous
x:\playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq\src\pg_libpq.h(55): warning C4005: 'THIS': macro redefinition (compiling source file ..\src\exec.cc) [X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq\build\pg_libpq.vcxproj]
  C:\Program Files (x86)\Windows Kits\8.1\Include\um\combaseapi.h(195): note: see previous definition of 'THIS' (compiling source file ..\src\exec.cc)
..\src\exec.cc(71): error C2061: syntax error: identifier 'uint' [X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq\build\pg_libpq.vcxproj]
..\src\exec.cc(89): error C2065: 'uint': undeclared identifier [X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq\build\pg_libpq.vcxproj]
..\src\exec.cc(89): error C2146: syntax error: missing ';' before identifier 'len' [X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq\build\pg_libpq.vcxproj]
..\src\exec.cc(89): error C2065: 'len': undeclared identifier [X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq\build\pg_libpq.vcxproj]
..\src\exec.cc(90): error C2065: 'len': undeclared identifier [X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq\build\pg_libpq.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (X:\Frameworks\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "X:\\Frameworks\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd X:\Playground\node-postgresql\pg-libpq-test\node_modules\pg-libpq
gyp ERR! node -v v0.12.4
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "X:\\Frameworks\\nodejs\\\\node.exe" "X:\\Frameworks\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "pg-libpq" "--save"
npm ERR! node v0.12.4
npm ERR! npm  v3.5.3
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the pg-libpq package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs pg-libpq
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls pg-libpq
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     X:\Playground\node-postgresql\pg-libpq-test\npm-debug.log

Connection object is successful only through callback consumption

First off, thanks for the library. I’m currently attempting to escape ORM hell and your library is situated perfectly, as you note, between node-pg and node-libpq. However, I’m encountering an issue wherein the connection object is never in a READY state when consuming the library as a Promise API, but connects successfully and is in a READY state when consumed via the callback interface. Looking at your source, it seems this just shouldn’t be happening, so perhaps theres an error on my part. So then, this ends up failing:

const PG = require('pg-libpq')
const SQL_PATH = `${process.cwd()}/migrations/sql`
const DATABASE_URL = process.env.DATABASE_URL
const { log, map, readAll, asynchronize } = require('../utils')

const pg = new PG(DATABASE_URL)

readAll(SQL_PATH)
  .then(files => map(file => file.toString(), files))
  .then(statements => asynchronize(migrate, pg, statements)) // asynchronize === co
  .catch(err => log(err))


function* migrate (client, statements) {
  log(client.isReady()) // FALSE, subsequent yield errs with connection not in ready state
  while(statements.length) {
    const statement = statements.unshift()
    const result = yield client.exec(statement)
    log(result)
  }
  client.finish()
}

But this shows up READY:

const PG = require('pg-libpq')
const SQL_PATH = `${process.cwd()}/migrations/sql`
const DATABASE_URL = process.env.DATABASE_URL
const { log, map, readAll, asynchronize } = require('../utils')

const pg = new PG(DATABASE_URL, (err, client) => log(client.isReady())) // TRUE

Built from source, test ends with Segmentation fault

Debian system with Postgres 10 or 10.1 and Node 8.9.1 or 9.1.0, does not matter

$ npm test

> [email protected] test /home/langpavel/Projects/work/postgres/node-pg-libpq
> tools/run-tests

/home/langpavel/Projects/work/postgres/node-pg-libpq
test: Entering directory '/home/langpavel/Projects/work/postgres/node-pg-libpq'


  ․Segmentation fault (core dumped)
npm ERR! Test failed.  See above for more details.

Failed to install on node 5.6.0, Linux x64

$ npm install
npm WARN deprecated [email protected]: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.

> [email protected] install /home/langpavel/Projects/node-pg-libpq
> node-gyp rebuild

make: Entering directory '/home/langpavel/Projects/node-pg-libpq/build'
  CXX(target) Release/obj.target/pg_libpq/src/exec.o
In file included from ../src/pg_libpq.h:5:0,
                 from ../src/exec.h:4,
                 from ../src/exec.cc:1:
../node_modules/nan/nan.h:324:27: error: redefinition of ‘template<class T> v8::Local<T> Nan::imp::NanEnsureHandleOrPersistent(const v8::Local<T>&)’
   NAN_INLINE v8::Local<T> NanEnsureHandleOrPersistent(const v8::Local<T> &val) {
                           ^
../node_modules/nan/nan.h:319:17: note: ‘template<class T> v8::Handle<T> Nan::imp::NanEnsureHandleOrPersistent(v8::Handle<T>&)’ previously declared here
   v8::Handle<T> NanEnsureHandleOrPersistent(const v8::Handle<T> &val) {
                 ^
../node_modules/nan/nan.h:344:27: error: redefinition of ‘template<class T> v8::Local<T> Nan::imp::NanEnsureLocal(v8::Handle<T>&)’
   NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Handle<T> &val) {
                           ^
../node_modules/nan/nan.h:334:27: note: ‘template<class T> v8::Local<T> Nan::imp::NanEnsureLocal(const v8::Local<T>&)’ previously declared here
   NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Local<T> &val) {
                           ^
../node_modules/nan/nan.h:757:13: error: ‘node::smalloc’ has not been declared
     , node::smalloc::FreeCallback callback
             ^
../node_modules/nan/nan.h:757:35: error: expected ‘,’ or ‘...’ before ‘callback’
     , node::smalloc::FreeCallback callback
                                   ^
../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(char*, size_t, int)’:
../node_modules/nan/nan.h:761:50: error: ‘callback’ was not declared in this scope
         v8::Isolate::GetCurrent(), data, length, callback, hint);
                                                  ^
../node_modules/nan/nan.h:761:60: error: ‘hint’ was not declared in this scope
         v8::Isolate::GetCurrent(), data, length, callback, hint);
                                                            ^
../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(const char*, uint32_t)’:
../node_modules/nan/nan.h:768:67: error: call of overloaded ‘New(v8::Isolate*, const char*&, uint32_t&)’ is ambiguous
     return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
                                                                   ^
../node_modules/nan/nan.h:768:67: note: candidates are:
In file included from ../node_modules/nan/nan.h:25:0,
                 from ../src/pg_libpq.h:5,
                 from ../src/exec.h:4,
                 from ../src/exec.cc:1:
/home/langpavel/.node-gyp/5.6.0/include/node/node_buffer.h:31:40: note: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, v8::Local<v8::String>, node::encoding) <near match>
 NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                        ^
/home/langpavel/.node-gyp/5.6.0/include/node/node_buffer.h:31:40: note:   no known conversion for argument 3 from ‘uint32_t {aka unsigned int}’ to ‘node::encoding’
/home/langpavel/.node-gyp/5.6.0/include/node/node_buffer.h:43:40: note: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, char*, size_t) <near match>
 NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                        ^
/home/langpavel/.node-gyp/5.6.0/include/node/node_buffer.h:43:40: note:   no known conversion for argument 2 from ‘const char*’ to ‘char*’
In file included from ../src/pg_libpq.h:5:0,
                 from ../src/exec.h:4,
                 from ../src/exec.cc:1:
../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(uint32_t)’:
../node_modules/nan/nan.h:772:61: error: could not convert ‘node::Buffer::New(v8::Isolate::GetCurrent(), ((size_t)size))’ from ‘v8::MaybeLocal<v8::Object>’ to ‘v8::Local<v8::Object>’
     return node::Buffer::New(v8::Isolate::GetCurrent(), size);
                                                             ^
../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanBufferUse(char*, uint32_t)’:
../node_modules/nan/nan.h:779:12: error: ‘Use’ is not a member of ‘node::Buffer’
     return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
            ^
pg_libpq.target.mk:93: recipe for target 'Release/obj.target/pg_libpq/src/exec.o' failed
make: *** [Release/obj.target/pg_libpq/src/exec.o] Error 1
make: Leaving directory '/home/langpavel/Projects/node-pg-libpq/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/langpavel/.nvm/versions/node/v5.6.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:100:13)
gyp ERR! stack     at ChildProcess.emit (events.js:185:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 3.16.0-4-amd64
gyp ERR! command "/home/langpavel/.nvm/versions/node/v5.6.0/bin/node" "/home/langpavel/.nvm/versions/node/v5.6.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/langpavel/Projects/node-pg-libpq
gyp ERR! node -v v5.6.0
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok 

npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/home/langpavel/.nvm/versions/node/v5.6.0/bin/node" "/home/langpavel/.nvm/versions/node/v5.6.0/bin/npm" "install"
npm ERR! node v5.6.0
npm ERR! npm  v3.6.0
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the pg-libpq package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs pg-libpq
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls pg-libpq
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/langpavel/Projects/node-pg-libpq/npm-debug.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.