Skip to content

Validity of callback not checked #1184

@Carbonyte

Description

@Carbonyte
client.query("SELECT now()", [], {});

This will happily execute, attempt to call the object, and crash Node. This isn't really the fault of node-postgres, but there's pretty much no way to catch the error besides process.on('uncaughtException'), and the Node docs explicitly advice against attempting to recover from any errors caught from there. Considering that this is a perfectly recoverable situation, this is not ideal, so node-postgres should check if the callback is actually a function before proceeding with the query. Even if it just throws an error, doing it before the query runs ensures the error's call stack contains code written by the developer, which allows it to be caught properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions