Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-6819 in a recent build.
  1. #1
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    975
    Vote Rating
    110
    Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all

      0  

    Default TaskRunner quietly catch errors

    TaskRunner quietly catch errors


    Hi everyone,

    Could someone clarify why does TaskRunner catch errors and doesn't show the error message in the console?

    Here is the sample to reproduce the issue.
    • Test case
    Code:
    <html>
    <head>
        <title>TaskRunner onError Issue</title>
    
        <link type="text/css" rel="stylesheet" href="../resources/css/ext-all.css" />
    
        <script type="text/javascript" src="../ext-all-debug.js"></script>
    
        <script type="text/javascript">
            Ext.onReady(function () {
                new Ext.Window({
                   height : 200,
                   width  : 200,
                   html   : "Look at the console log. There is no error which can confuse a developer."  
                }).show("div1", function () {
                    throw "Some error"; // Just for testing. Some real error can occur here.
                });
            });
        </script>
    </head>
    <body>
        <div id="div1" style="width: 100px;">Animation Target</div>
    </body>
    </html>
    There is no error in the console due to the fact that it's caught internally within the onTick function of the Ext.util.TaskRunner class. As far as I can understand the TaskRunner class is used when a Window is shown with some animation target to monitor the animation proccess is finished or not before running the callback. If you would pass "null" as the first argument of the show method, the error will appear in the console.

    I am asking, because it just misled me a bit when I investigated some issue. The issue appeared due to the JS error occurred in the callback, but I did not see that error in the console and I was digging in a wrong place.

    Should not the TaskRunner, at least, print the error message in the console?

    Thanks.

  2. #2
    Sencha - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,962
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      1  

    Cool


    @Daniil -

    TaskRunner was re-written for 4.1 to allow for an onError callback function to be specified on the Task:
    Code:
    var config = {
            run     : function() {},
            interval : 1000,
            onError : function(task, error){}
        },
        task = new Ext.util.TaskRunner.Task(config);
    To setup a default Handler for any Task, just implement your own sugar:
    Code:
    Ext.require([ 'Ext.util.TaskRunner.*' ], function() {
        Ext.util.TaskRunner.Task.override ({
           onError  : function(task, error) { console.dir( error ); }
      });
    });
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  3. #3
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    975
    Vote Rating
    110
    Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all

      0  

    Default


    Hi Doug,

    Thanks for the answer. Good.

    So, the own default onError function looks a single way to catch the error in this case:
    Code:
    win.show('someTarget', callback);
    Isn't that so?

    Or am I missing something and there is a possibility to set up an onError handler in that case?

  4. #4
    Sencha - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,962
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Default


    @Daniil --

    The Window.show callback is managed by the (deeply nested) Animator and TaskRunner is not even involved there.

    For maximum control, your best bet would be to setup a try{}catch right in the callback.
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  5. #5
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    975
    Vote Rating
    110
    Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all

      0  

    Default


    Then where is the JS error caught?

    I believe Animator uses TaskRunner.

    Here is the chain:

    Ext.fx.Animator uses Ext.fx.Manager.

    There is the addAnim function which calls
    Code:
    Ext.TaskManager.start(task);
    Ext.TaskManager is a subclass of Ext.util.TaskRunner.

  6. #6
    Sencha - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,962
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Default


    Sorry, yes, you are correct.

    The Task created by the Animation sequence cannot be defined or influenced by the current Window.show method (the deeply nested problem I was referring too).

    You choices are limited to a try{}catch within the callback or,
    throw any error again with the override mentioned previously:

    Code:
    Ext.require([ 'Ext.util.TaskRunner.*' ], function() {            
       Ext.util.TaskRunner.Task.override ({        
            onError  : function(task, error) { if( error )throw error; }   
        }); 
    });
    ... to simulate the original behaviour of releases previous to 4.1.
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  7. #7
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    975
    Vote Rating
    110
    Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all

      0  

    Default


    Agree, overriding the default onError looks to be a good option.

    "Try catch" within each callback can annoy.

    Ok, got it. Thanks for your time.

    Personally, that is not a problem for me anymore.

    But, I am afraid, it possibly can lead other developers to get some "hard to fix" issues.

    Maybe, it would be better to do not catch errors by default and optionally (for example, TaskRunner global setting) change the behavior?

    Just thoughts. Maybe someone how was the initiator of this change would like to revise that

  8. #8
    Sencha - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,962
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Default


    @Daniil --

    Glad you've got a work-around. I'll admit, I'm head-scratchin' the 'silent errors issue' this creates. I'll kick this around a bit internally.
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  9. #9
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Posts
    1,365
    Vote Rating
    135
    dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold

      0  

    Default


    We addressed TaskRunner 4.1 to optimize it for large numbers of timers (Doug, you may recall your work on Stateful flushing... this was a result of taming the number of timers it would create).

    Due to that work, we noticed that if we allowed one task to throw an exception, it would stay scheduled and immediately ready to run. This caused a busy spin on the queue and would also starve other tasks in the queue since the dispatch loop would abort.

    The role of TaskRunner is to aggregate timers and share them between tasks. Uncontrolled exceptions make that job harder/slower if we don't catch them and allow the dispatch loop to proceed. Which is why we added the onError callback - but exceptions from there are also caught.

    All that said - we should certainly have log statements for errors in dev mode.
    Don Griffin
    Ext JS Development Team Lead

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

    "Use the source, Luke!"

  10. #10
    Sencha - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,962
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Default


    Thanks Don
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


Thread Participants: 3

Tags for this Thread