Results 1 to 9 of 9

Thread: [FIXED][3.??] Ext.Direct "exception" event raises "tid has no properties" error

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User j.bruni's Avatar
    Join Date
    Jun 2009
    Location
    Uberlândia, MG, Brazil
    Posts
    106

    Question [FIXED][3.??] Ext.Direct "exception" event raises "tid has no properties" error

    I am using a Ext.data.DirectStore to get data from server.

    I am dealing with a "tid has no properties" error at ext-all-debug.js line 13944 (using ExtJS 3 RC 2)

    This happens when the server response is not parsable (in my case, PHP code generated an error, and instead of the beauty JSON, the response is PHP's error messages)

    I found that the Ext.data.JsonProvider is creating the Ext.Direct.ExceptionEvent (see code below from ext-all-debug.js line 14057)

    Code:
    /**
     * @class Ext.direct.JsonProvider
     * @extends Ext.direct.Provider
     */
    Ext.direct.JsonProvider = Ext.extend(Ext.direct.Provider, {
        parseResponse: function(xhr){
            if(!Ext.isEmpty(xhr.responseText)){
                if(typeof xhr.responseText == 'object'){
                    return xhr.responseText;
                }
                return Ext.decode(xhr.responseText);
            }
            return null;
        },
    
        getEvents: function(xhr){
            var data = null;
            try{
                data = this.parseResponse(xhr);
            }catch(e){
                var event = new Ext.Direct.ExceptionEvent({
                    data: e,
                    xhr: xhr,
                    code: Ext.Direct.exceptions.PARSE,
                    message: 'Error parsing json response: \n\n ' + data
                })
                return [event];
            }
            var events = [];
            if(Ext.isArray(data)){
                for(var i = 0, len = data.length; i < len; i++){
                    events.push(Ext.Direct.createEvent(data[i]));
                }
            }else{
                events.push(Ext.Direct.createEvent(data));
            }
            return events;
        }
    });
    But at its subclass Ext.Direct.RemotingProvider onData method, we have a call to the event's "getTransaction" method (see code below from ext-all-debug.js line 14242)

    Code:
        onData: function(opt, success, xhr){
            if(success){
                var events = this.getEvents(xhr);
                for(var i = 0, len = events.length; i < len; i++){
                    var e = events[i];
                    var t = e.getTransaction();
                    this.fireEvent('data', this, e);
                    if(t){
                        this.doCallback(t, e, true);
                        Ext.Direct.removeTransaction(t);
                    }
                }
    But the event has no "transaction" nor "tid" set, thus generating the error.

    What shall I do?

    Thanks!

  2. #2
    Sencha User j.bruni's Avatar
    Join Date
    Jun 2009
    Location
    Uberlândia, MG, Brazil
    Posts
    106

    Smile Solution found

    Ok, I just did a small adjustment and everything runs fine now.

    Code:
        onData: function(opt, success, xhr){
            if(success){
                var events = this.getEvents(xhr);
                for(var i = 0, len = events.length; i < len; i++){
                    var e = events[i];
                    var t = e.getTransaction();
                    var t = this.getTransaction(e);
                    this.fireEvent('data', this, e);
                    if(t){
                        this.doCallback(t, e, true);
                        Ext.Direct.removeTransaction(t);
                    }
                }
    This is code from Ext.data.RemotingProvider onData method (ext-all-debug.js line 14242)

  3. #3
    Sencha User j.bruni's Avatar
    Join Date
    Jun 2009
    Location
    Uberlândia, MG, Brazil
    Posts
    106

    Thumbs up Can this be corrected into SVN? (if it was not already corrected)

    Well... the only issue now is that I can't change other people's ExtJS source code...

    How can this correction be commited to the SVN?
    (Although I believe this was probably already done...)

    Who may I contact or request? Is this the correct Forum to ask for this? Who is the boss here?

    Thanks!

  4. #4
    Ext JS Premium Member stever's Avatar
    Join Date
    Mar 2007
    Posts
    1,408

    Default

    Thanks!

  5. #5
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,239

    Default

    This hay have already been resolved, please post a test case that demonstrates the issue.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  6. #6
    Sencha User j.bruni's Avatar
    Join Date
    Jun 2009
    Location
    Uberlândia, MG, Brazil
    Posts
    106

    Arrow How to reproduce this bug

    As suggested, I am providing the following code as a test case:

    Code:
    Ext.app.REMOTING_API = { 
      'url': 'router.txt',
      'type': 'remoting',
      'actions': { 'remoteStore': [{"name":"load","len":2}] }
    };
    
    Ext.Direct.addProvider( Ext.app.REMOTING_API );
    
    var grid = {
      xtype: 'editorgrid',
      title: 'Nice Editor Grid',
      frame: true,
      store: {
        xtype: 'directstore',
        storeId: 'niceStore',
        // proxy
        paramOrder: [ 'sort', 'dir' ],
        paramsAsHash: false,
        directFn: remoteStore.load,
        // reader
        totalProperty: 'total',
        root: 'rows',
        idProperty: 'id',
        fields: [ 'user_id', 'user_name' ],
        // store
        remoteSort: true,
        sortInfo: {
          field: 'user_name',
          direction: 'ASC'
        }
      },
      columns: [
        { header: 'User ID',   dataIndex: 'user_id'  , sortable: false, menuDisabled: true },
        { header: 'User Name', dataIndex: 'user_name', sortable: false, menuDisabled: true }
      ],
      tbar: [{ 
        xtype: 'tbbutton', 
        text: 'Ext.StoreMgr.get(\'niceStore\').load();', 
        handler: function() {
          Ext.StoreMgr.get('niceStore').load();
        }
      }]
    };
    
    // below, we are setting an event handler for ExceptionEvent
    // to display an alert showing some exception's details
    Ext.Direct.on( 'exception', function(e) { 
      Ext.Msg.alert( 'Failure' , 
        'e.code: ' + e.code + '<br><br>' + 
        'e.message: ' + e.message + '<br><br>' + 
        'e.xhr.responseText: ' + e.xhr.responseText
      );
    });
    
    function doLayout() {
      new Ext.Viewport({
        layout: 'fit',
        items: grid
      });
    }
    
    Ext.onReady( doLayout );
    If you run the above code in ExtJS 3 RC 2, you will see a button in a top toolbar.
    Click it to run the code in red. It calls the DirectStore "load" method:

    Code:
    Ext.StoreMgr.get('niceStore').load();
    What happens?

    It depends on our server response.
    In this test case, we configured the remoting API with a a "fake" server-side router: router.txt
    We have three possibilities:

    1)
    There is no "router.txt" (404 error)
    The alert window is displayed, with the exception's details.
    No problem here.

    2) "router.txt" containing proper JSON response - for example:

    Code:
    {"type":"rpc","tid":2,"action":"remoteStore","method":"load","result":{"id":"user_id","total":3,"success"
    :true,"rows":[{"user_id":3,"user_name":"Asterix"},{"user_id":1,"user_name":"Felix, the Cat"},{"user_id"
    :2,"user_name":"Garfield"}]}}
    The grid will be populated with the response's data. Success!
    No problem here.

    3) "router.txt" containing not-JSON response - for example:

    Code:
    not a JSON string
    Here is the problem! In this case... sometimes nothing will happen at all. No exceptions. No errors. No data. No alert. This is not bad. A response with NO data... nothing loaded in the store... nothing to display in the grid. That's ok, but...

    ...sometimes you will got a "tid has no properties" error at ext-all-debug.js line 13944 !!!

    So, that's why I have put a button in the toolbar to call the Store's load method.
    Maybe you will got the error in the first click/call. Maybe in the second or third...

    What was expected?

    Instead of "tid has no properties" error, I'd like to see the alert containing the exception's details.

    This is exactly what happens after changing the code as suggested in the previous post!

    Thanks for your attention!
    Attached Files Attached Files

  7. #7
    Sencha User j.bruni's Avatar
    Join Date
    Jun 2009
    Location
    Uberlândia, MG, Brazil
    Posts
    106

    Lightbulb Development Environment currently being used

    FYI...

    OS: Linux Mandriva 2008.0
    Browser: Firefox 2.0.0.18 with Firebug 1.3.1
    Server: Apache 2.2.6 (localhost)

  8. #8
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,239

    Default

    Thanks for the detailed test case. Your fix has been committed to SVN.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  9. #9
    Sencha User j.bruni's Avatar
    Join Date
    Jun 2009
    Location
    Uberlândia, MG, Brazil
    Posts
    106

    Smile

    Great! Thanks!

    I look forward to the ExtJS 3 release! Congratulations for the hard and good work!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •