Return-Path: X-Original-To: apmail-cordova-issues-archive@minotaur.apache.org Delivered-To: apmail-cordova-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 58E1018FEE for ; Tue, 13 Oct 2015 16:36:05 +0000 (UTC) Received: (qmail 90067 invoked by uid 500); 13 Oct 2015 16:36:05 -0000 Delivered-To: apmail-cordova-issues-archive@cordova.apache.org Received: (qmail 90043 invoked by uid 500); 13 Oct 2015 16:36:05 -0000 Mailing-List: contact issues-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@cordova.apache.org Received: (qmail 90028 invoked by uid 99); 13 Oct 2015 16:36:05 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Oct 2015 16:36:05 +0000 Date: Tue, 13 Oct 2015 16:36:05 +0000 (UTC) From: "Steven Wexler (JIRA)" To: issues@cordova.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CB-9256) Errors in subscribed event callbacks prevent other subscribed callbacks from being invoked MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CB-9256?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14955237#comment-14955237 ] Steven Wexler commented on CB-9256: ----------------------------------- :( > Errors in subscribed event callbacks prevent other subscribed callbacks from being invoked > ------------------------------------------------------------------------------------------ > > Key: CB-9256 > URL: https://issues.apache.org/jira/browse/CB-9256 > Project: Apache Cordova > Issue Type: Bug > Components: CordovaJS > Reporter: Steven Wexler > Priority: Critical > > Let's say I register two callbacks for the "deviceReady" event before the event fires. If the first callback hits an error, the second callback will not be invoked > {code} > document.addEventListener("deviceready", function () { throw new Error("oops"); }); > document.addeventListener("deviceready", function () { /*never hit*/ }); > {code} > This behavior differs if the events were registered after the event was fired. > I think the following code should handle callbacks that fail: > https://github.com/apache/cordova-js/blob/master/src/common/channel.js#L213 > {code} > for (var i = 0; i < toCall.length; ++i) { > toCall[i].apply(this, fireArgs); > } > {code} > Should be something like: > {code} > var errors = []; > for (var i = 0; i < toCall.length; ++i) { > try { > toCall[i].apply(this, fireArgs); > } catch (e) { > errors.push(e); > } > } > for (var j = 0; j < errors.length; ++j) { > (function (arg) { > setTimeout(function () { throw errors[arg]; }); > })(j); > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org For additional commands, e-mail: issues-help@cordova.apache.org