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

Ensure transactions are always #505

Merged
merged 1 commit into from
May 25, 2017
Merged

Ensure transactions are always #505

merged 1 commit into from
May 25, 2017

Conversation

stefanpenner
Copy link
Contributor

@stefanpenner stefanpenner commented May 24, 2017

  • need to see if this actually fixes the problem
  • tests
  • review

fixes #484

@stefanpenner
Copy link
Contributor Author

stefanpenner commented May 24, 2017

Although I think ^ should be added, this wont address all cases (or even that many cases) as.

begin -> commit are actually the public API for interacting with then VM, so code from the calling library between they two may still fail. Which means that could also needs the try/finally.

Question is, should we enforce the commit, or implement a "abort" transaction.

let needsAbort = true;
try {
  env.begin();
  env.commit();
  needsAbort = false; // everything went ok, no abort required.
} finally { 
  if (needsAbort) {
    env.abort();
  }
}

Alternatively, one could remove the assertion and merely assume begin -> begin means, release the last transaction and create a new one. (no nesting).

@stefanpenner
Copy link
Contributor Author

Rather then enforcing the caller to be aware of this. I change the PR to take a different approach.

  • commit always resets the active transaction to null
  • calling begin with an active transaction warns, then commits that transaction, and then starts the next transaction.

@stefanpenner
Copy link
Contributor Author

There are different ways we can skin this cat, would love others opinions.

let transaction = this._transaction;
if (transaction) {
this._transaction = null;
LOGGER.warn('a glimmer transaction was begun, but one already exists. You may have a nested transaction');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

throw in debug

@krisselden
Copy link
Contributor

This looks good

* ensure running `commit` always clears the current transaction
* if we begin a transaction with an existing transaction warn, commit it, then start begin the next.
@krisselden
Copy link
Contributor

I like the fix, I'm not crazy about the test, why not throw on a component hook once like didInsertElement and test that you can rerender again?

@stefanpenner stefanpenner merged commit c62bcce into master May 25, 2017
@stefanpenner stefanpenner deleted the maybe-fix branch May 25, 2017 17:34
@Turbo87 Turbo87 changed the title [BUGFIX #484] ensure transactions are always. Ensure transactions are always Oct 22, 2017
@Turbo87 Turbo87 added the bug label Oct 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Errors regarding nested transactions
4 participants