-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Handle throws in type parsers #1218
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
Conversation
lib/query.js
Outdated
row = this._result.parseRow(msg.fields); | ||
} catch (err) { | ||
if(this.callback) { | ||
return this.callback(err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will call the callback at least twice if there are errors: once for each errored row, and then once to incorrectly indicate a successful completion, with errored rows missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, looking into it now 👍
@charmander should be fixed now :) |
f309a21
to
8a01e1d
Compare
8a01e1d
to
a0c341c
Compare
@charmander Studied the code more carefully and came up with what I think is a more proper solution. This should now handle the errors correctly and the tests should test it properly (e.g. was missing |
test('handles throws in type parsers', function() { | ||
|
||
types.setTypeParser('special oid that will throw', function () { | ||
throw Object.assign(new Error('Test'), { throwInTypeParser: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Object.assign
isn’t compatible with Node ≤ 0.12.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be best to create the error outside the type parser and check that it’s equal to the emitted error rather than adding throwInTypeParser
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very smart, I'll fix that today 👌
I don't think this failure is related to my commit :) restarting the build... |
703f12d
to
fd30e95
Compare
🤔 same error again, seems like something is broken on Travis or the Node.js releases server... |
fd30e95
to
2c4b363
Compare
...and the build passes! 🎉 🎉 |
ping @brianc, any chance of getting this merged? :) |
ping @brianc, I would really appreciate it if we could merge this one 🙌 |
Nevermind - I see what's going on now - had to read the entire query file. |
Publishing new patch version to npm now - sorry for the delay. |
Thank you ❤️ |
Fixes #1204