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

Uncaught error: attempted to handle event deleteRecord while in state root.loaded.updated.inFlight #14352

Closed
alidcast opened this issue Sep 26, 2016 · 2 comments

Comments

@alidcast
Copy link

I'm getting these two errors in conjunction:

Uncaught Error: Attempted to handle event `deleteRecord` on <studbits@model:note::ember778:4> while in state root.loaded.updated.inFlight.

Uncaught Error: Assertion Failed: You modified transitioningIn twice in a single render. This was unreliable and slow in Ember 1.x and is no longer supported. 

I'm not sure about the first error, but the second one is said to reference this issue. As discussed there, "In the middle of the rendering process, I have modified something that has already been rendered".

At first, I thought it was because I was using different references of my model (getting one for the controller and another one in the component). But even when I give the model as an argument (as shown below) the error persists.

Here's an example code that causes this:

// template.js
<div class="note-body" {{action 'saveNote' note on='focusOut'}}>
  {{mobiledoc-editor}}
</div>

<button {{action 'deleteNote' note}}>Delete</button>

// component.js
actions: {
    saveNote(note) { // triggered on focus out
      this.sendAction('save', note);
    },

    deleteNote(note) { // triggered when button pressed
      this.sendAction('delete', note);
  }

when I try to delete an object with saveNote() commented out, everything works fine. But when both coexist together, I get the aforementioned errors and can't seem to work my way around them.

If this is indeed where the problem lies, what would be a correct way to have such two actions (e.g. an autosave and delete button) coincide with Glimmer 2?

@locks
Copy link
Contributor

locks commented Sep 26, 2016

This isn't related to Glimmer.

The problem here is that when you click the button you are focusing out of note-buddy, so it runs the associated action handler. This means that you trigger a save, and a delete immediately after, and Ember Data gives you the errors at the top of your post. Maybe you can handle the focusOut event at the component level instead?

If you require further assistance, post on Stack Overflow or reach us on Slack. Thanks for reporting!

@locks locks closed this as completed Sep 26, 2016
@Mifrill
Copy link

Mifrill commented Dec 8, 2020

Was resolved for me by:

if (!model.isDestroyed && !model.isDestroying) {
  model.deleteRecord();
}

in this particular case, I guess:

if (!note.isDestroyed && !note.isDestroying) {
  this.sendAction('delete', note);
}

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

No branches or pull requests

3 participants