Skip to content
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

Allow nested transactions when global transaction is in place #497

Closed
wants to merge 3 commits into from

Conversation

MZanggl
Copy link
Contributor

@MZanggl MZanggl commented Oct 21, 2019

Proposed changes

The fix addresses the following issue adonisjs/vow#22.
I also had issues on my own, where I would get Error: Test timeout, ensure "done()" is called; if returning a Promise, ensure it resolves. in some places.

Types of changes

What types of changes does your code introduce?

Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if appropriate)

Further comments

Ideally beginTransaction would just be

if (this._globalTrx) {
   return this._globalTrx.transaction()
}

return this.knex.transaction()

but I think the knex version first has to be updated to include this fix here knex/knex#3393

@coveralls
Copy link

coveralls commented Oct 21, 2019

Coverage Status

Coverage decreased (-78.6%) to 17.926% when pulling ce10f16 on MZanggl:bugfix/savepoints into 6cd666d on adonisjs:develop.

Comment on lines -182 to +188
this
.knex
.transaction(function (trx) {
resolve(trx)
}).catch(() => {})
this.knex.transaction(resolve).catch(() => {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be off topic, but why are we catching without rejecting? Not ever rejecting just causes the promise to be left pending indefinitely. In a web app this can cause a server to crash if enough transactions fail (e.g. database is overloaded). A preferable outcome would be to reject so that the server can handle the result gracefully.

@MZanggl
Copy link
Contributor Author

MZanggl commented Nov 2, 2019

Seems the builds are failing for reasons outside of my change. I remember the first time they were all successful. I also tried retriggering it :/

$ npm install sqlite3 --save

Cannot find module '/home/travis/build/adonisjs/adonis-lucid/node_modules/sqlite3/lib/binding/node-v79-linux-x64/node_sqlite3.node'

@stale
Copy link

stale bot commented Dec 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Abandoned Dropped and not into consideration label Dec 4, 2020
@stale stale bot closed this Dec 11, 2020
@thetutlage thetutlage removed the Status: Abandoned Dropped and not into consideration label Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants