Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-7710

V8 build isn't supporting some stored JavaScript that SpiderMonkey build could handle

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.4.0-rc2
    • 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.

            Assignee:
            tad Tad Marshall
            Reporter:
            tad Tad Marshall
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: