-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: JavaScript
-
None
-
Environment:Tested using PyMongo driver
-
ALL
This code works in both SpiderMonkey and V8 builds:
C:\> python Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pymongo >>> c = pymongo.Connection(port=27999) >>> db = c.test >>> db.system_js.foo = "function(){return 5;}" >>> db.system_js.foo() 5.0
This code works in SpiderMonkey builds but not in V8 builds:
SpiderMonkey
>>> db2.system_js.bar = "return 5;"
>>> db2.system_js.bar()
5.0
V8
>>> db.system_js.bar = "return 5;" >>> db.system_js.bar() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\pymongo\database.py", line 776, in <lambda> scope={'name': name}), *args) File "C:\Python27\lib\site-packages\pymongo\database.py", line 716, in eval result = self.command("$eval", code, args=args) File "C:\Python27\lib\site-packages\pymongo\database.py", line 355, in command msg, allowable_errors) File "C:\Python27\lib\site-packages\pymongo\helpers.py", line 129, in _check_command_response raise OperationFailure(msg % response["errmsg"]) pymongo.errors.OperationFailure: command SON([('$eval', Code('function() { return this[name].apply(this, arguments); }', {'name': 'bar'})), ('args', ())]) failed: invoke failed: error in invoke: _funcs1:1 TypeError: Cannot call method 'apply' of null _funcs1 = function() { return this[name].apply(this, arguments); } ^
The V8 server shows this as a "compile" error:
<unknown>:33: Uncaught SyntaxError: Unexpected token return Mon Nov 19 10:32:38.381 [conn1] Could not compile function: ____MongoToV8_newFunction_temp = return 5; Mon Nov 19 10:32:38.396 [conn1] error in invoke: _funcs1:1 TypeError: Cannot call method 'apply' of null _funcs1 = function() { return this[name].apply(this, arguments); } ^
The way that stored functions are being processed in the V8 build requires them to be assignable as presented, so "function()
{<stuff>}" works but "<stuff>" doesn't work.
- related to
-
SERVER-7705 ReferenceError executing stored JS with V8 causes nightly to segfault.
- Closed