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
Fix return duplicate transaction promise for standalone transactions #3328
Conversation
@vonagam One test is failing. |
Should be fixed now. But |
Fixed typo in Also |
@vonagam A different test on postgreSQL is failing now. |
Yes, i know. This test was failing before, but silently, it was producing unhandled rejections before, now the test properly fails because Here is the link to an unhandled rejection warning for this test when it was introduced, so it was actually not passing from the start. (By the way i include line numbers in my links to travis logs, but unfortunately travis does not scroll to specified rows) I can't run postgres tests (some issue with a connection... maybe figure it out later), i was running only sqlite tests on my machine before. |
Fixed it. |
get(res, 'context.sql', '').toUpperCase() === 'ROLLBACK' && | ||
this.doNotRejectOnRollback | ||
) { | ||
if (this.doNotRejectOnRollback && /^ROLLBACK\b/i.test(sql)) { |
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.
Should this be case-sensitive?
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 change is probably also needed for db dialect transaction implementations that have their own rollback handling.
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.
I mean https://github.com/tgriesser/knex/blob/master/src/dialects/mysql/transaction.js, doesn't look like any other dialect has this logic.
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.
-
Current implementation is case-insensitive, so that's why i added
/i
flag to make the regexp case-insensitive too. But actually it does not need to be case-insensitive, since only valid way to rollback or commit is thoughtrx.rollback()
ortrx.commit()
, only they setstatus
argument, so only they_resolve()
or_reject()
, so only they release a connection properly, and they use upper case, so actually there is no need for/i
flag, i just kept it to be similar to current implementation. -
Other dialects do usual rollback fine, since only postgres was failing the test. But i assume they do nested rollback badly (first issue). So yeah, other dialects should be updated to treat
rollbackTo()
queries the same way asrollback()
, but it will require new tests for such cases and new PR. I just wanted to make current tests pass.
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.
Fair enough!
So it seems like #3319 was a mistake and having a duplicate is needed because original execution promise does have
catch
attached so it will never produce unhandled rejections. So if you do not attachcatch
toexecutionPromise
nobody will tell you that your transaction queries are failing (except this debug statement).Solution: promise duplication but only for standalone transactions.