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

Stored JavaScript fails when starting with var keyword

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.1.9
    • Affects Version/s: 2.4.1, 2.4.3
    • Component/s: JavaScript
    • None
    • Fully Compatible
    • ALL
    • Hide

      db.system.js.save({_id:"foo", value:"var root=this;"})
      db.loadServerScripts()

      Show
      db.system.js.save({_id:"foo", value:"var root=this;"}) db.loadServerScripts()
    • Build 9 (09/18/15)

      When saving script into system.js, if the script starts with the var keyword (example, var root = this;), the script will fail to load when trying to use the script from a map reduce or even db.loadServerScripts() from the shell produces:

      JavaScript execution failed: Error: 16722 JavaScript execution failed: SyntaxError: Unexpected token var at src/mongo/shell/db.js:L1001
      

      The was not a problem in 2.2.x, and doesn't appear to be a problem in a 64-bit Linux build (2.4.3).

            Assignee:
            jonathan.reams@mongodb.com Jonathan Reams
            Reporter:
            bitmask Scott Allen
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: