DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
    • can-construct-super
    • can-define-stream
    • can-fixture
    • can-fixture-socket
    • can-jquery
    • can-stache-converters
    • can-stream
    • can-vdom
    • can-view-import
    • can-zone
      • types
        • ZoneSpec
        • makeZoneSpec
      • static
        • current
        • error
        • ignore
        • waitFor
      • prototype
        • addWait
        • data
        • removeWait
        • run
      • plugins
        • ./debug
          • DebugInfo
        • ./timeout
      • modules
        • ./register
    • steal-stache
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Ecosystem
  • /
  • can-zone
  • /
  • ./debug
  • / On this page
    • can-zone/debug

      module
      • source

      debug(ms)

      Creates a new ZoneSpec that can be provided to your Zone, timing out in ms (milliseconds).

      var Zone = require("can-zone");
      var debug = require("can-zone/debug");
      
      var zone = new Zone({
          plugins: [debug(5000)]
      })
      .catch(function(err){
          var info = zone.data.debugInfo;
      });
      

      See the DebugInfo type for a list of properties

      Parameters

      1. ms {Number}:

        The timeout, in milliseconds, before the Zone will be rejected and debug information attached to the zone's data object.

      debug(timeoutZone)

      Like the previous signature, but directly pass it a timeout ZoneSpec object that you create yourself.

      var debug = require("can-zone/debug");
      var timeout = require("can-zone/timeout");
      
      var timeoutZone = timeout(5000);
      var debugZone = debug(timeoutZone):
      
      ...
      

      Parameters

      1. timeoutZone {can-zone/timeout}:

        A ZoneSpec created using the timeout plugin.

      Use

      The debug zone gives you information about which tasks failed to complete in case of a timeout. It is to be used with ./timeout.md.

      When a timeout occurs the debug Zone will appending debug information to the Zone's data property, which can be retrieved when the Zone's promise is rejected:

      var debug = require("can-zone/debug");
      var Zone = require("can-zone");
      
      var zone = new Zone(debug(5000);
      
      zone.run(function(){
      
          setTimeout(function(){}, 10000);
      
      }).catch(err){
      
          var debugInfo = zone.data.debugInfo;
      
      });
      

      DebugInfo

      The DebugInfo is an array of objects that contain information about which tasks failed to complete. Each object has a shape of:

      {
          "task": "setTimeout",
          "stack": Error ...."
      }
      

      DebugInfo[].task

      A string identifier of the task that failed to complete. This can be any of the asynchronous tasks supported by can-zone like setTimeout or Promise.

      DebugInfo[].stack

      A string stack trace taken as a snapshot when the task was called. This allows you t see the source of the call to help debug why the task never completed.

      debug(timeout)

      Create a debug Zone by passing the debug function a timeout in milliseconds:

      var debug = require("can-zone/debug");
      var Zone = require("can-zone");
      
      new Zone({
          plugins: [
              debug(5000)
          ]
      });
      

      debug(timeoutZone)

      Create a debug Zone by passing in a timeout Zone that was already created:

      var timeout = require("can-zone/timeout");
      var debug = require("can-zone/debug");
      var Zone = require("can-zone");
      
      var timeoutZone = timeout(5000);
      var debugZone = debug(timeoutZone);
      
      new Zone({
          plugins: [
              timeoutZone,
              debugZone
          ]
      });
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.