wulczer/txpostgres

Connection.runInteraction() may not close cursor?

Closed this issue · 3 comments

I just read through the source for runInteraction() since the documentation left me wondering whether I was supposed to manually close the cursor in the supplied function. (Apparently not.)

If I'm reading this right, rollbackAndPassthrough() will always return a Failure, causing the callback that closes the cursor to never be called since the errback will be called instead? Shouldn't it be addBoth() instead of addCallback() for the c.close() lambda? Or am I missing something?

Ah, you're right, it's not closing the cursor in case of an error. I don't think the last addCallback() should be an addBoth() but there should be a close() call inside rollbackAndPassthrough().

Good catch, will fix.

Thanks for the report, I made the docs clearer on that and made sure the cursor is always closed.

Oh, and turned out you were right, it should have been addBoth() :)

Beware that this probably broke disconnecting during interaction execution, see #37 for how fixing runQuery() this way broke the disconnectWhileRunning test.