neumino / rethinkdbdash

An advanced Node.js driver for RethinkDB with a connection pool, support for streams etc.
MIT License
848 stars 109 forks source link

Configuration flag to show failed queries #90

Closed thelinuxlich closed 9 years ago

thelinuxlich commented 9 years ago

This would help debugging errors a lot, instead of throwing something like ReqlDriverError messages, also provide the full query parsed by the adapter

neumino commented 9 years ago

Can you give more details on what this flag would do?

Why not just let bluebird handle and print them?

thelinuxlich commented 9 years ago

I don't know what you mean, bluebird doesn't show the final query.

An example, if I'm debugging a complex ReQL query throwing something like

ReqlDriverError
Cannot convert `undefined` with r.expr().

I need to do something like this

console.log(query.toString());

To see what's going on

neumino commented 9 years ago

In case of undefined, you can just look at the stracktrace. It will point you to the line that fails.

It also throws in this case because undefined values are not treated as operational errors like NaN.

thelinuxlich commented 9 years ago

Well, the line that fails is the line containing the whole query before parsing, so it doesn't help much

neumino commented 9 years ago

Is undefined the only error that bothers you?

thelinuxlich commented 9 years ago

No, most of the errors, when dealing with long queries, I need to see the parsed result

neumino commented 9 years ago

Oh I see. Some errors don't seem to properly bubbled up. I'll fix that and make undefined an operational error. That should fix your problems I think.

thelinuxlich commented 9 years ago

Is this still valid or your latest error patches solved it?

neumino commented 9 years ago

It should be fixed now. Tests are here: https://github.com/neumino/rethinkdbdash/blob/master/test/client-backtrace.js#L70

And backtraces look like this:

Cannot convert `Infinity` to JSON in:
r.db("dd054a14db348f5bcb99bbf14615955c").table("2f66694bbfa2a7bd2f0b0ef0460e7178")
    .map(function(var_1) {
        return var_1("key").add(Infinity)
                                ^^^^^^^^ 
    })
thelinuxlich commented 9 years ago

This will be a life saver!