Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-2240

Following the "Browser (no bundling)" in the README leads to missing "global"

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • bson-4.2.0
    • Affects Version/s: bson-4.0.2
    • Component/s: BSON
    • Labels:
      None
    • Environment:
      No transpiling, browser environment, using {{dist/bson.browser.js}}

      From https://github.com/mongodb/js-bson/issues/330 :

      Following the instruction in the section "Browser (no bundling)" doesn't work.

      On line 3726, "global" is used, which is apparently not defined in browsers.

      In Firefox:

      ReferenceError: global is not defined                                  bson.bundle.js:3726:6
          BSON https://automower2/js/bson.bundle.js:3726
          <anonymous> https://automower2/js/bson.bundle.js:9112
      

      Chrome has a similar error.

      I'm not sure if this deserves a separate issue because it might be related. The "with bundling" section also has the same problem, and it seems the offending lines of code come from elsewhere:

      if (typeof global.setTimeout === 'function') {
        cachedSetTimeout = setTimeout;
      }
      
      if (typeof global.clearTimeout === 'function') {
        cachedClearTimeout = clearTimeout;
      }
      

      one more...

      var performance = global.performance || {};

            Assignee:
            Unassigned Unassigned
            Reporter:
            daniel.aprahamian@mongodb.com Daniel Aprahamian (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: