brianc / node-libpq

Simple, low level native bindings to PostgreSQL's libpq from node.js
112 stars 42 forks source link

startReader doesn't work on windows #21

Closed sasha-alias closed 8 years ago

sasha-alias commented 9 years ago

Can't read result of async query on windows client. The query itself gets to the database with no issues. I see it in pg_stat_activity.

Example:

var PQ = require('libpq');
var pq = new PQ();

pq.connect(function(err) {
    if (err){
        console.log('Connection error: '+err);
        return;
    }

    pq.on('readable', function(){
        console.log('ready');
        pq.consumeInput();
    });

    var sent = pq.sendQuery('select pg_sleep(5);');

    if (!sent){
        console.log('Query sending error: '+pq.errorMessage());
        return;
    }

    pq.startReader();
}
);

Output:

Assertion failed: handle->type == UV_POLL, file src\win\poll.c, line 219

On non-windows platforms works as expected:

ready
Nekuromento commented 9 years ago

Can confirm, encountered the same issue with version 1.6.4

brianc commented 9 years ago

Sorry i dont have access to a windows machine to test. This code base is pretty small and clean if you want to dive in and submit a patch that would be awesome!

On Wednesday, July 8, 2015, Max Klyga notifications@github.com wrote:

Can confirm, encountered the same issue with version 1.6.4

— Reply to this email directly or view it on GitHub https://github.com/brianc/node-libpq/issues/21#issuecomment-119567984.

sasha-alias commented 9 years ago

I actually tried to dive in, but I miss the deeper knowledge of lubuv library. It fails there on asserts https://github.com/libuv/libuv/blob/v1.x/src/win/poll.c#L219 I was able to hack around of first two by changing node-libpq code, but not the third one in line 221. Need help.

motiz88 commented 8 years ago

@sasha-alias I wonder if you can take a look at #38 and see if it solves your issue too. I was hitting the same assertion (via simple async use of node-postgres) and now it seems OK.

sasha-alias commented 8 years ago

thanks, I will test it

sasha-alias commented 8 years ago

Thanks a lot @motiz88 it works