2012-11-20 19 views
5

私はExtJS 4.1を使用していますが、タイムアウトが発生するとGoogle Chromeでキャッチされない例外が発生します。タイムアウト後のキャッチされない例外ChromeのExt.Ajax.request

Ext.Ajax.timeout = 10000; // 10 seconds 
Ext.Ajax.method = "GET"; 
Ext.Ajax.request({ 
    url:'rest/dataloggerset.json', 
    params:{ 
      sessionGuid:Ext.getStore("User").getAt(0).get("sessionGuid"), 
      loggerId:this.availableLogFiles.loggerId, 
      logSet:this.currentLog 
    }, 
    success:this.processReceivedLogData, 
    failure:this.failureDuringResourceLoad, 
    scope:this 
}); 

要求はタイムアウトで終了し、これまで受信したデータはオブジェクト内で解析されようとします。だから私は、デベロッパーコンソールで見ているキャッチされない例外は、次のようになります。

不明なエラー:INVALID_STATE_ERR:DOM例外11 Connection.js:914 Ext.define.createResponse Connection.js:914 Ext.define。 onCompleteのConnection.js:859 Ext.define.abort Connection.js:767 request.timeout

この問題はFFに出てくることはありません。キャッチされない例外のため、私のメソッドfailureDuringResourceLoadは呼び出されません。

言及する価値はありますが、定義されたタイムアウトが経過してもデータは送信され続けます。

+0

localhost /またはfile://から実行していますか? – A1rPun

+0

ローカルホスト/ http://server.com/ – Chris

+0

[他のSOエントリをチェックしましたか?](http://stackoverflow.com/questions/2357430/invalid-state-err-dom-exception-11) – A1rPun

答えて

3

私はいくつかの調査の後、xhr.abort()の動作がChromeとFFで異なることを発見しました。クロムでは、xhr.statusは変更されずに200のままですが、FFのステータスはxhr.abort()を呼び出した後に0に設定されます。

この違いはExtJS 4.1で有効な応答として誤ってタイムアウトが要求されるという影響をもたらします。タイムアウトのシナリオを処理するために、次のオーバーライドを使用しました。 ExtJS 4.1では、要求オブジェクトの変数は、タイムアウトが発生した場合にマークします。このオーバーライドは、onCompleteメソッドを置き換えます。

Ext.define('Df.data.Connection', { 
    override: 'Ext.data.Connection', 

    onComplete : function(request) { 
     var me = this, 
      options = request.options, 
      result, 
      success, 
      response; 

     try { 
      result = me.parseStatus(request.xhr.status); 
     } catch (e) { 
      // in some browsers we can't access the status if the readyState is not 4, so the request has failed 
      result = { 
       success : false, 
       isException : false 
      }; 
     } 

     success = result.success && !request.timedout; 

     if (success) { 
      response = me.createResponse(request); 
      me.fireEvent('requestcomplete', me, response, options); 
      Ext.callback(options.success, options.scope, [response, options]); 
     } else { 
      if (result.isException || request.aborted || request.timedout) { 
      response = me.createException(request); 
      } else { 
       response = me.createResponse(request); 
      } 
      me.fireEvent('requestexception', me, response, options); 
      Ext.callback(options.failure, options.scope, [response, options]); 
     } 
     Ext.callback(options.callback, options.scope, [options, success, response]); 
     delete me.requests[request.id]; 
     return response; 
    } 
}); 

変更はConnection.jsの元の場所の856行で確認できます。私に知らせてください。この問題を解決するためのより便利な方法がある場合は

success = result.success && !request.timedout; 

:私はに

success = result.success; 

を拡張しました!

+1

+1 [ExtJS bug forum](http://www.sencha.com/forum/forumdisplay.php?80-Ext-Bugs)に投稿する –

+0

thx Rob、私はお勧めしました! – Chris

関連する問題