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

Use globalThis for global variable access in test runner standard libraries

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • Server Serverless 2023-02-06

      The core set of libraries included in the test runner (nee "shell") are injected in all new javascript scopes before any test code is run. These libraries define a number of global variables (such as rs, sh, etc) which may be overwritten accidentally by jstests which unintentionally shadow those variables. This has traditionally been avoided by aggressive use of IIFEs in jstests, but part of the process of converting the test corpus to es modules includes unwrapping those IIFE-guarded tests. A solution to this problem is to have the standard libraries always prefix their access of these global variables with globalThis, so that we are guaranteed access of the global variable rather than any lexically scoped, shadowed variant within jstest code.

            Assignee:
            matt.broadstone@mongodb.com Matt Broadstone
            Reporter:
            matt.broadstone@mongodb.com Matt Broadstone
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: