Skip to content
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

Unhandled 'error' event #337

Closed
drewhamlett opened this issue Jun 21, 2014 · 1 comment
Closed

Unhandled 'error' event #337

drewhamlett opened this issue Jun 21, 2014 · 1 comment
Labels
bug

Comments

@drewhamlett
Copy link

@drewhamlett drewhamlett commented Jun 21, 2014

I'm using Postgres

knex('user')
    .select('email')
    .where({
        email: 'blah@blah.com'
    })
    .stream(function (stream) {
        stream.on('data', function (data) {
            console.log(data)
        });
    }).catch(function (e) {
        console.error(e);
    });

This throws this error

events.js:72
        throw er; // Unhandled 'error' event
              ^
error: syntax error at end of input
    at Connection.parseE (/Users/drewh/node/mturk/node_modules/pg/lib/connection.js:526:11)
    at Connection.parseMessage (/Users/drewh/node/mturk/node_modules/pg/lib/connection.js:356:17)
    at Socket.<anonymous> (/Users/drewh/node/mturk/node_modules/pg/lib/connection.js:105:22)
    at Socket.emit (events.js:95:17)
    at Socket.<anonymous> (_stream_readable.js:748:14)
    at Socket.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:410:10)
    at emitReadable (_stream_readable.js:406:5)
    at readableAddChunk (_stream_readable.js:168:9)
    at Socket.Readable.push (_stream_readable.js:130:10)

This does not

knex('user')
    .select('email')
    .stream(function (stream) {
        stream.on('data', function (data) {
            console.log(data)
        });
    }).catch(function (e) {
        console.error(e);
    });

I also can't use this syntax for streams.

var stream = knex('user').select('email').stream();

stream.on('data', function (data) {
    console.log(data)
});

I get this.
TypeError: Object [object Promise] has no method 'on'

I'm on Knex 0.6.16

With these dependencies.

"pg": "^3.3.0",
"pg-query-stream": "^0.6.0",

Thanks for any help!

@tgriesser tgriesser closed this in a1be2e9 Jun 25, 2014
@tgriesser tgriesser added bug labels Jun 25, 2014
@tgriesser
Copy link
Member

@tgriesser tgriesser commented Jun 25, 2014

I believe this should be fixed now, let me know if you're still having issues.

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

Successfully merging a pull request may close this issue.

None yet
2 participants