DoneJS StealJS jQuery++ FuncUnit DocumentJS
4.3.0
5.0.0 3.13.1 2.3.35
  • About
  • Guides
  • API Docs
  • Community
  • Contributing
  • Bitovi
    • Bitovi.com
    • Blog
    • Design
    • Development
    • Training
    • Open Source
    • About
    • Contact Us
  • About
  • Guides
  • API Docs
    • Observables
      • can-bind
      • can-compute
      • can-debug
      • can-define
      • can-define/list/list
      • can-define/map/map
      • can-define-backup
      • can-define-stream
      • can-define-stream-kefir
      • can-event-queue
      • can-kefir
      • can-list
      • can-map
      • can-map-define
      • can-observation
      • can-observation-recorder
      • can-observe
      • can-simple-map
      • can-simple-observable
      • can-stream
      • can-stream-kefir
      • can-value
    • Data Modeling
      • can-connect
      • can-connect-feathers
      • can-fixture
      • can-fixture-socket
      • can-ndjson-stream
      • can-set
    • Views
      • can-component
      • can-stache
      • can-stache-bindings
      • can-stache-converters
      • can-stache-route-helpers
      • can-view-autorender
      • can-view-callbacks
      • can-view-import
      • can-view-live
      • can-view-model
      • can-view-nodelist
      • can-view-parser
      • can-view-scope
      • can-view-target
      • react-view-model
      • react-view-model/component
      • steal-stache
    • Routing
      • can-deparam
      • can-param
      • can-route
      • can-route-hash
      • can-route-mock
      • can-route-pushstate
    • JS Utilities
      • can-assign
      • can-define-lazy-value
      • can-diff
      • can-globals
      • can-join-uris
      • can-key
      • can-key-tree
      • can-make-map
      • can-parse-uri
      • can-queues
      • can-string
      • can-string-to-any
      • can-util
      • can-zone
        • types
          • ZoneSpec
          • makeZoneSpec
        • static
          • current
          • error
          • ignore
          • waitFor
        • prototype
          • addWait
          • data
          • removeWait
          • run
        • plugins
          • ./debug
            • DebugInfo
          • ./timeout
        • modules
          • ./register
      • can-zone-storage
    • DOM Utilities
      • can-ajax
      • can-attribute-encoder
      • can-child-nodes
      • can-control
      • can-dom-data
      • can-dom-events
      • can-dom-mutate
      • can-event-dom-enter
      • can-event-dom-radiochange
      • can-fragment
    • Data Validation
      • can-define-validate-validatejs
      • can-validate
      • can-validate-interface
      • can-validate-legacy
      • can-validate-validatejs
    • Typed Data
      • can-cid
      • can-construct
      • can-construct-super
      • can-data-types
      • can-namespace
      • can-reflect
      • can-reflect-dependencies
      • can-reflect-promise
      • can-types
    • Polyfills
      • can-symbol
      • can-vdom
    • Core
    • Infrastructure
      • can-global
      • can-test-helpers
    • Ecosystem
    • Legacy
  • Community
  • Contributing
  • GitHub
  • Twitter
  • Chat
  • Forum
  • News
Bitovi

can-zone/debug

  • Edit on GitHub

debug(ms)

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

import Zone from "can-zone";
import debug from "can-zone/debug";

const zone = new Zone( {
    plugins: [ debug( 5000 ) ]
} )
    .catch( function( err ) {
        const 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.

import debug from "can-zone/debug";
import timeout from "can-zone/timeout";

const timeoutZone = timeout( 5000 );
const debugZone = debug( timeoutZone );

// ...

Parameters

  1. timeoutZone {can-zone/timeout}:

    A ZoneSpec created using the timeout plugin.

debug(timeoutOrTimeoutZone, options)

Creates a new ZoneSpec using either a timeout in milliseconds, or a timeout ZoneSpec, along with an options object. The following options are available:

Parameters

  1. timeoutOrTimeoutZone {Number|can-zone/timeout}:

    Either a Number timeout, or a timeout ZoneSpec.

  2. options {Object}:

    An options object with the following parameters:

    • break (Boolean): When enabled, causes a debugger; statement to be hit after the timeout is complete. This allows stepping into the code that is preventing the Zone's run promise from completing.

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:

import debug from "can-zone/debug";
import Zone from "can-zone";

const zone = new Zone( debug( 5000 ) );

zone.run( function() {

    setTimeout( function() {}, 10000 );

} ).catch( function( err ) {

    const 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:

import debug from "can-zone/debug";
import Zone from "can-zone";

new Zone( [
    debug( 5000 )
] );

debug(timeoutZone)

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

import timeout from "can-zone/timeout";
import debug from "can-zone/debug";
import Zone from "can-zone";

const timeoutZone = timeout( 5000 );
const debugZone = debug( timeoutZone );

new Zone( [
    timeoutZone,
    debugZone
] );

Break on timeout

The default behavior of the debug zone is to store stack traces on zone.data.debugInfo. Some times it is easier to actually step into the code that is running. You can enable this behavior by setting the break option like so:

import Zone from "can-zone";
import debug from "can-zone/debug";

const zone = new Zone( [
    debug( 5000, { break: true } )
] );

When the zone times out you'll dropped into this breakpoint:

Break on timeout

As the comment says, you can step into the proceeding function to find the code that is responsible for the zone's run promise not completing.

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

On this page

Get help

  • Chat with us
  • File an issue
  • Ask questions
  • Read latest news