[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13198718#comment-13198718 ] Jason Smith commented on COUCHDB-1302: -- This ticket is listed as a 1.2 blocker. But Randall asked to open a new ticket for 1.2; so where do we stand? Today I got CouchDB working against the Firefox 10 spidermonkey but I'd like to know the roadmap for this issue, plus a place to post patches. Thanks. Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Attachments: 0001-Prevent-linking-against-too-new-of-a-SpiderMonkey.patch, 0002-Minor-fixes-to-link-agianst-SpiderMonkey-trunk.patch Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
Re: [jira] [Commented] (COUCHDB-1302) Fix couchjs
Sorry, please disregard. I did not realize the issue was closed. If I'm not wrong, the discussion for 1.2 is COUCHDB-1397. On Thu, Feb 2, 2012 at 11:57 AM, Jason Smith (Commented) (JIRA) j...@apache.org wrote: [ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13198718#comment-13198718 ] Jason Smith commented on COUCHDB-1302: -- This ticket is listed as a 1.2 blocker. But Randall asked to open a new ticket for 1.2; so where do we stand? Today I got CouchDB working against the Firefox 10 spidermonkey but I'd like to know the roadmap for this issue, plus a place to post patches. Thanks. Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Attachments: 0001-Prevent-linking-against-too-new-of-a-SpiderMonkey.patch, 0002-Minor-fixes-to-link-agianst-SpiderMonkey-trunk.patch Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira -- Iris Couch
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13164443#comment-13164443 ] afters commented on COUCHDB-1302: - Not sure if it's relevant, but here's how I checked if a string is indeed an anonymous function: (https://github.com/afters/Couch-Incarnate/blob/master/lib/syncer.js#L38) var verifyMapStringIsFunction = function () { var basicFuncTemplate = new RegExp( '^' + '\\s*' + 'function' + '\\s*' + '\\(([^\\)]*)\\)' + '\\s*' + '{([\\s\\S]*)}' + '\\s*' + '$' ); var match = basicFuncTemplate.exec(map.fn); if (!match) throw new Error(); try { var argsStr = match[1]; var bodyStr = match[2]; new Function(argsStr, bodyStr); } catch (e) { throw new Error(); } } Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Attachments: 0001-Prevent-linking-against-too-new-of-a-SpiderMonkey.patch, 0002-Minor-fixes-to-link-agianst-SpiderMonkey-trunk.patch Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13136217#comment-13136217 ] Jens Alfke commented on COUCHDB-1302: - For what it's worth: I ran into the exact same issue last month while working on experimental support for using WebKit's JavaScriptCore instead of SpiderMonkey in emonk. JSC has never supported that anonymous-function hack. Good to know this is going to get resolved in couchdb going forward. Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Attachments: 0001-Prevent-linking-against-too-new-of-a-SpiderMonkey.patch, 0002-Minor-fixes-to-link-agianst-SpiderMonkey-trunk.patch Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13125637#comment-13125637 ] Randall Leeds commented on COUCHDB-1302: Tested 1.1.x with Paul's patches applied. I checked it against a few spidermonkey versions including debian unstable from the iceweasel package, ubuntu's xulrunner-1.9.2.17-dev and libmozjs185-dev. Verified that the configure throws an error on the new one. Didn't check spidermonkey trunk, but I trust that patch 0002 is fine. I say commit it for 1.1.x and we can start the release process, then open a new ticket to talk about what to do about 1.2. Thanks, Paul! Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Attachments: 0001-Prevent-linking-against-too-new-of-a-SpiderMonkey.patch, 0002-Minor-fixes-to-link-agianst-SpiderMonkey-trunk.patch Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13124555#comment-13124555 ] Damjan Georgievski commented on COUCHDB-1302: - My proposal is for CouchDB functions to be treated as CommonJS modules (http://wiki.commonjs.org/wiki/Modules/1.1) i.e. they would look like: exports = function(doc) { emit bla bla } btw, this seems to work even today in 1.2.x + vanilla 1.8.5 spidermonkey Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Attachments: 0001-Prevent-linking-against-too-new-of-a-SpiderMonkey.patch, 0002-Minor-fixes-to-link-agianst-SpiderMonkey-trunk.patch Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13124557#comment-13124557 ] Randall Leeds commented on COUCHDB-1302: Paul: +1 on both patches. I might like Damjan's proposal. We should start that ticket for 1.2+. Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Attachments: 0001-Prevent-linking-against-too-new-of-a-SpiderMonkey.patch, 0002-Minor-fixes-to-link-agianst-SpiderMonkey-trunk.patch Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13122562#comment-13122562 ] Benoit Chesneau commented on COUCHDB-1302: -- I was thinking this morning on this function naming. I'm not sure it's really needed. Why not considering map other functions like code we just need to evaluate. Something like : { map: emit(doc._id, null); } So we can eventually encapsulate it in our function. This pattern is commonly used. You can found it for example in last redis script feature or in elasticsearch. It would also simplify a lot the syntax and the way we can write and debug such functions. Thoughts ? Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
Re: [jira] [Commented] (COUCHDB-1302) Fix couchjs
Randall asked that I note for posterity that uglify.js may help. It seems to be 100% Javascript, CommonJS (not just a Node), BSD license. It gives you the Javascript abstract syntax tree. I was thinking of using it for input validation. Perhaps, instead of all sorts of new ideas, just make the breaking change that you *must* stick to the normal CouchDB way, one function in a string. Here is how you can confirm a standard map function. That could be in the view server, just before you eval() it. http://friendpaste.com/7LdkWzEfGgrLTKYdo7JENm // Confirm a valid old-school CouchDB map function. var uglify = require('uglify-js') , assert = require('assert'); var old_map = function(doc) { emit(doc._id, 1) } var code, ast; code = old_map; try { ast = uglify.parser.parse('(' + code + ')'); assert.equal(ast[0], 'toplevel'); var statements = ast[1]; assert.equal(statements.length, 1); var func_expr = statements[0]; assert.equal(func_expr.length, 2); assert.equal(func_expr[0], 'stat'); var func_def = func_expr[1]; assert.equal(func_def[0], 'function'); if(process.env.require_name) assert.equal(func_def[1], 'map'); var formals = func_def[2]; assert.ok(formals.length = 1); console.log('Good code:\n' + code); } catch(e) { console.log('Bad code:\n' + code); if(ast) console.log('\nAST:\n' + JSON.stringify(ast)); } On Fri, Oct 7, 2011 at 10:58 AM, Paul Joseph Davis (Commented) (JIRA) j...@apache.org wrote: [ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13122519#comment-13122519 ] Paul Joseph Davis commented on COUCHDB-1302: I agree with Randall. I think we have a plan for 1.1.1 that's sane. The 1.2 can of worms is going to be a big one so we should make sure and separate the issues there. Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira -- Iris Couch
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13122622#comment-13122622 ] Paul Joseph Davis commented on COUCHDB-1302: I'm not entirely sure what you mean about encapsulation, but just evaling code and hoping for the best doesn't seem like the best solution here. When you eval something, it runs. So this case means we'd have to eval the function once per doc per view. Plus, other things. Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13122633#comment-13122633 ] Benoit Chesneau commented on COUCHDB-1302: -- I don't follow Since you get a string from the json , you can then easily do eval(function map(doc) { + themapstring + }) map(doc) doesn't change anything. And you won't have to check that map is really called as map in the json string. Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13122643#comment-13122643 ] Paul Joseph Davis commented on COUCHDB-1302: Source manipulations worry me. That's basically what I tired doing with the paren hack before thinking better of it and that's turned out to be quite a bad idea. As far as I'm concerned, if it can't be implemented at the level of the JSAPI, then its nothing more than hack that is just going to lead to more pain down the road. I'm all for tools that we don't rely on directly to help users find incompatible code, but those sorts of things don't strike me as having a place in trunk. Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13122652#comment-13122652 ] Paul Joseph Davis commented on COUCHDB-1302: On the face of it, I'm not a fan of this. It seems... wrong. But its late so maybe I'm just not seeing it. Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13121748#comment-13121748 ] Paul Joseph Davis commented on COUCHDB-1302: From Benoit on the ML: if we do that it would imply the release of a major version since the change is major. I'm +1 to introduce correct behaviour in trunk rather than trying to hack arouind our own insanity. I think its a good idea to revert this on 1.1.x as it could break user code for no good reason. Though 1.1.x will have the ability to use newer SpiderMonkey's, they'll have to deal with upgrading their JS code. What we do about 1.2.x and trunk I'm less certain. On the one hand, we could save some people some effort. On the other hand, we'd also be breaking things for people that use helper functions that haven't upgraded to 1.8.5 or w/e version of SM introduces this. Bottom line is that there's no good answer other than making sure we note it in our NEWS files, and on the website and also try and document it in error messages. Quite an unfortunate situation that I see no good answer to. Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13121871#comment-13121871 ] Riyad Kalla commented on COUCHDB-1302: -- Now is the perfect opportunity to make this change, once 1.2/2.0 goes out the door it likely couldn't be safely addressed again until 3.0 and the uptake in CouchDB (from what I see at least) seems to be on the rapid rise. Making this change in 1.2/2.0 becomes an education issue, so maybe some questions around how to be *really* helpful explaining the situation to the user, e.g. errors in the server log when the problem is encountered and exactly how to work around it pointing at a Wiki page with clarification explaining why; maybe warnings during startup when the server does a quick scan for the issue (that can be disabled if the user knows they have a good setup); Sure it will be painful, but trying to monkey-patch this until 3.0 (or beyond) will be much more painful and have a lot more negative impact by that time. I like Jason's suggestion of some quick-patch tool that might ship with the install that attempts the fix automatically or at least gives the users enough tools and help/information so as to get them from Point A to B as quickly as possible. Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13122206#comment-13122206 ] Paul Joseph Davis commented on COUCHDB-1302: Ok. Here's the situation: First, an anonymous function at the root of a scope is invalid JavaScript. Ie, the following is invalid: function(doc) {emit(doc._id, 1);} Is broken JavaScript. But, SpiderMonkey has had an option for years [1] that allowed this. SpiderMonkey happened to be the only interpreter that has had this. The setting JSOPTION_ANONFUNFIX existed to enforce the error mechanism. The thing is, it was off by default (ie, the error was not triggered by default) in older js shells. Recently, this appears to have caused an error for SpiderMonkey passing the JavaScript test suite [2]. Along with this patch, the js shell from SM 1.8.5 enables JSOPTION_ANONFUNFIX so all of the js shell tests we were doing were misleading. couchjs works with the 1.8.5 tarball from Mozilla. It does not work starting when [2] was applied to trunk (after the 1.8.5 tarball was created). So bottom line, this isn't an issue for all of the tarballs from Mozilla's official FTP site, but it will be an issue moving forward. So the plan I'm proposing is this: 1. Re-enable support for 1.8.5 on 1.1.x for 1.1.1 2. Revert the paren hack across the board. 3. Add a configure check for JSOPTION_ANONFUNFIX so we can detect if user code will break (and perhaps add an option to override it) 4. Update 1.2.x with some new behavior that will force people to upgrade all of their function definitions to be correct moving forward. Also note that this would be backwards compatible if the named function is the last statement as we currently require which should be enforceable in the future (if we so desire). I think 1, 2, and 3 are relatively uncontroversial at this point. We now know how to detect exactly when old code will break and can warn about it (ie, by refusing to build, (the option to override I'm less certain about, I'd be +0.5 at this point)). As to 4, the behavior I would propose at this point is that all of our JS definitions would require a name in the future. For instance: function(doc) {emit(doc._id, 1);} becomes: function map(doc) {emit(doc._id, 1);} And then couchjs+main.js gets modified to look for these specific names. I'm thinking we'd end up with map, reduce, filter, validate, show, list, and update given our current set of user definable functions. For users we'd also need to make our error messages better. Currently, the error without these names would be something generic like expression does not evaluate to a function or similar which could be change to something like No function named 'map' or similar (though, that obviously needs work cause it could be a real syntax error as well). So, 1, 2, and 3 have my +1. I think 4 is probably best going forward, but we can open a new ticket about how to deal with the it for 1.2. [1] https://bugzilla.mozilla.org/show_bug.cgi?id=377433 [2] https://bugzilla.mozilla.org/show_bug.cgi?id=665835 Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13122217#comment-13122217 ] Adam Kocoloski commented on COUCHDB-1302: - +1 from me on points 1,2,3. Thanks for tracking this down Paul. Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13122252#comment-13122252 ] Noah Slater commented on COUCHDB-1302: -- I am +0 on having an over-ride ./configure flag. The rest seem perfectly reasonable, so +1 on those. Even 4 sounds okay, TBH. Though I'd be open to seeing other suggestions too! Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13122274#comment-13122274 ] Benoit Chesneau commented on COUCHDB-1302: -- +1 on 1,2,3 . thanks :) Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13122280#comment-13122280 ] Robert Newson commented on COUCHDB-1302: +1 on 1,2,3. Not keen on configure option in 1.1.1 but will go with the flow (though let's decide soon pls). for point 4, while that signature looks much nicer, is it too much of a break for 1.2? Feels like a 2.0 thing. If there's agreement, then the remaining question is what branch becomes 2.0. Oh, the joy. Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13122427#comment-13122427 ] Randall Leeds commented on COUCHDB-1302: +1 on 1 and 2. +1 for 3. I'll write this up for 1.1.x if Paul doesn't beat me to it. 1.2/2.0 needs something different though. Paul discovered and mentioned in IRC that we can't actually look for the last function if people use named functions because eval('function map(...){...}') === undefined. In other words, we need to pull 'map' out of the global scope after the call to eval() so it needs to have a well-known name. So we're stuck opening up the 2.0 can of worms it seems. We should consider what the cleanest looking design document that makes this all look sane is and what effect any changes have on the way we index and optimize work for calculating design doc indexes. We should focus on 1.1.1 and then open the bikeshed floodgates. Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13122519#comment-13122519 ] Paul Joseph Davis commented on COUCHDB-1302: I agree with Randall. I think we have a plan for 1.1.1 that's sane. The 1.2 can of worms is going to be a big one so we should make sure and separate the issues there. Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13121578#comment-13121578 ] Paul Joseph Davis commented on COUCHDB-1302: So I sat down today to try and figure out this SpiderMonkey issue. After a chat with the guys on #jsapi they specifically said wrap it in parens when I asked. Though the issue is that it gets a bit more tricky. The situation is basically that we've apparently been using invalid JavaScript for the last four years. Specifically, a script like such is invalid: function(){} Sadly, that's how *all* of our callbacks are expected to be defined. When I mentioned this, the suggestion was exactly to wrap it in parens which is what I'd discovered on my own. This works fine except for that people that have defined functions outside the callback scope then hit issues. Ie: var f = function() {}; function() {f();}; Breaks when wrapped in parens. And it even breaks when not in parens because the anonymous function still needs to be wrapped like such: var f = function() {}; (function(){f();}) So, we're kinda up shit creek here. I'm still trying to figure out if there's anything we can do to save users pain, but the recommendation was basically, It was fixed on purpose and its a hardcoded change that can't be configured. So, either we tell users fix your functions or we try and do some sort of source level analysis to wrap that last function, or something entirely different. Anyone else have Ideas? Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13121591#comment-13121591 ] Paul Joseph Davis commented on COUCHDB-1302: I thought to ask the SpiderMonkey hackers how crazy it was to try and do source level analysis to automatically wrap that last anonymous function in parens. Jason Orendorff is on record as saying it would be hopeless to try and hack that outside of the SpiderMonkey engine. The only other thing I can think of would be to try and hack JSLint's parser to do this for us. Other than that, I think we really are up shit creek here. Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (COUCHDB-1302) Fix couchjs
[ https://issues.apache.org/jira/browse/COUCHDB-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13121691#comment-13121691 ] Jason Smith commented on COUCHDB-1302: -- Couch Javascript are expressions, not statements. Everything is an implicit var map = eval(ddoc.views.by_name.map). You put function expressions in them. Helpers must go in inside. If helpers don't fit in new couchjs, that can't be helped. It is not a breaking change so much, except that couch permitted a convenient but severe syntax error and now it doesn't. One can also argue that the place for helper code is CommonJS modules. We discussed parsing JS with uglify.js and identifying the final function defined. This allows unmodified ddocs to work. But developers communicate to CouchDB extremely implicitly and through an invisible mechanism. It feels like being an enabler. Assuming uglify.js can do it, how would you feel about a correction tool which converts bad code to good code? We could test it in the real world as a couchapp or web service that converts bad ddocs to good ddocs. If it works well, maybe even bundle it into couchjs and couch could be told to correct the errors. When asked, couch could feed the design doc to couchjs with the uglify fixer tool and update the ddoc with the correction. Maybe /_config/couchdb/fix_my_js = true. The fix could run when ddocs are read, or perhaps saved, or who knows! even during compaction. This is a crazy idea but IMO less crazy than permitting invalid Javascript that upstream code has sought to eliminate. To me the best trade-off is to mark it in the change log and provide third-party tools to correct ddocs. Fix couchjs --- Key: COUCHDB-1302 URL: https://issues.apache.org/jira/browse/COUCHDB-1302 Project: CouchDB Issue Type: Improvement Components: JavaScript View Server Affects Versions: 1.1.1, 1.2, 1.3 Reporter: Paul Joseph Davis Priority: Blocker Figure out why some spidermonkeys have an error when doing: eval(function(){}) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira