Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
1.3.1, 1.4.0, 1.5.0
-
None
-
None
Description
The module cache is breaking update functions which share a common module via require(). Disabling the caching by adding || true in main.js at line 1174 (CouchDB 1.5.0) resolves the problem. With this disabled then both curl commands in the example pass.
This code was introduced in https://issues.apache.org/jira/browse/COUCHDB-1075
Here is a complete test case design document which demonstrates the problem.
{
"_id": "_design/ptest",
"updates": {
"two": "function(doc, req) {\n\trequire('views/lib/docUtil');\n\n\tif(!doc) {\n\t\tdoc = {};\n\t}\n\n\tdoc._id = 'two';\n\n\tdoc.meta = docUtil.metaCreate();\n\n\treturn([doc, JSON.stringify(doc, undefined, 2)]);\n}",
"one": "function(doc, req) {\n\trequire('views/lib/docUtil');\n\n\tif(!doc) {\n\t\tdoc = {};\n\t}\n\n\tdoc._id = 'one';\n\n\tdoc.meta = docUtil.metaCreate();\n\n\treturn([doc, JSON.stringify(doc, undefined, 2)]);\n}"
},
"language": "javascript",
"views": {
"lib": {
"docUtil": "(function(global) {\n\nvar _metaCreate = function() {\n\treturn(
);\n};\n\nvar _metaModify = function() {\n\treturn(
{\n\t\ta: 'modify',\n\t\tb: 'bbbb'\n\t});\n};\n\nglobal.docUtil =
{\n\tmetaCreate: _metaCreate,\n\tmetaModify: _metaModify\n};\n\nlog('require docUtil');\n\n})(exports.docUtil = this)"
}
},
"type": "design/ptest"
}
Call the update functions like:
curl -X POST http://couchdb:5984/zydev/_design/ptest/_update/one - creates a document
curl -X POST http://couchdb:5984/zydev/_design/ptest/_update/two - fails