I'm implementing the row editing for my treepanel, but it isn't working as I expected, sometimes the update action distorts my treepanel and sometimes doesn't. Also I'm having problems with the sync function:

Code:
onEdited:function(){
        console.log(this.getStore().getUpdatedRecords().length);
        this.getStore().sync();
    }
The first time I update a record I get on the console:
1
And the record is updated in the database.
If I perform another update I expect the same results but, instead I get:
2
and an Internal Server Error :S

Any Ideas?