Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 05F08EF8B for ; Sun, 3 Feb 2013 15:32:15 +0000 (UTC) Received: (qmail 12358 invoked by uid 500); 3 Feb 2013 15:32:15 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 12023 invoked by uid 500); 3 Feb 2013 15:32:14 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 11977 invoked by uid 99); 3 Feb 2013 15:32:13 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Feb 2013 15:32:13 +0000 Date: Sun, 3 Feb 2013 15:32:13 +0000 (UTC) From: "Max Desyatov (JIRA)" To: dev@couchdb.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (COUCHDB-1075) Circular require's in CommonJS modules 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/COUCHDB-1075?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13569803#comment-13569803 ] Max Desyatov commented on COUCHDB-1075: --------------------------------------- Circular require still doesn't work in 1.2.1, at least in validation functions. Try this one { "_id": "_design/validation", "validate_doc_update": "function (newDoc, oldDoc, userCtx, secObj) {\n if (!(newDoc._deleted != null)) {\n throw {\n forbidden: require('lib/test').meow\n };\n }\n }", "lib": { "test": "exports.blah = 1234; var two = require('./two'); exports.meow = two.meh + 1;", "two": "var test = require('./test'); exports.meh = test.blah + 1;" } } Expected result is 1236. In CouchDB 1.2.1 it always throws null, though according to CommonJS Modules spec (even 1.0): "If there is a dependency cycle, the foreign module may not have finished executing at the time it is required by one of its transitive dependencies; in this case, the object returned by "require" must contain at least the exports that the foreign module has prepared before the call to require that led to the current module's execution." > Circular require's in CommonJS modules > -------------------------------------- > > Key: COUCHDB-1075 > URL: https://issues.apache.org/jira/browse/COUCHDB-1075 > Project: CouchDB > Issue Type: Bug > Components: JavaScript View Server > Reporter: Caolan McMahon > Labels: javascript > Fix For: 1.2 > > Attachments: module_cache.diff > > > Having a CommonJS module A which requires B, when B also requires A causes the stack to fill up with require calls. A prerequisite for this fix is the caching of modules, even if it is only on a per-request basis. > Patch incoming. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira