Sinon: Upgrade of Browserify fails tests

Created on 7 Aug 2019  Β·  21Comments  Β·  Source: sinonjs/sinon

  • Sinon version : master (before updating) or branch bug-updating-deps
  • Environment : Chromium

What did you expect to happen?
All tests pass in all environments.

What actually happens
One test fails.

  1360 passing (919ms)
  4 pending
  1 failing

  1) fakeTimers.clock
       .useFakeTimers
         fakes provided methods:
     AssertionError: [refute.same] function onNextTick() {} expected not to be the same object as function onNextTick() {}
      at Object.fail (node_modules/@sinonjs/referee/lib/create-fail.js:5)
      at Object.fail (node_modules/@sinonjs/referee/lib/define-assertion.js:46)
      at assertion (node_modules/@sinonjs/referee/lib/define-assertion.js:68)
      at Function.referee.<computed>.<computed> [as same] (node_modules/@sinonjs/referee/lib/define-assertion.js:93)
      at Context.<anonymous> (test/util/fake-timers-test.js:1075)

How to reproduce

Check out master (671330ce). Run npm update && npm test.

Also pushed the updates: https://github.com/sinonjs/sinon/commit/c8ff2b8f6f438ccac7c5c3abd9a106dc84914610

Tough Help wanted

All 21 comments

Tried to manually revert one package at a time (tried browserify, rollup, ++), without seeing a difference.

Now trying the reverse using a script by just installing and testing one package at a time.

Success. [email protected] does something different.

$ cat test-script.sh 
#!/bin/bash

set -e # exit on error
pkgs=([email protected] [email protected] [email protected] [email protected] [email protected])
for pkg in $pkgs; do
    git reset --hard
    npm install $pkg
    npm test
done

I can't find anything suspicious in the diff: https://github.com/browserify/browserify/compare/v16.2.3...v16.3.0?

The package-lock.json for the update does include one interesting part of the diff:

        "process-nextick-args": {
          "version": "2.0.1",
        },


Full diff (git diff package-lock.json | egrep -v 'resolved|integrity|"dev"')

diff --git a/package-lock.json b/package-lock.json
index e12873c6..23ea8984 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -409,29 +409,29 @@
     },
     "acorn-node": {
-      "version": "1.6.2",
+      "version": "1.7.0",
       "requires": {
-        "acorn": "^6.0.2",
+        "acorn": "^6.1.1",
         "acorn-dynamic-import": "^4.0.0",
-        "acorn-walk": "^6.1.0",
+        "acorn-walk": "^6.1.1",
         "xtend": "^4.0.1"
       },
       "dependencies": {
         "acorn": {
-          "version": "6.0.4",
+          "version": "6.2.1",
         }
       }
     },
     "acorn-walk": {
-      "version": "6.1.1",
+      "version": "6.2.0",
     },
     "agent-base": {
@@ -607,12 +607,30 @@
       }
     },
     "assert": {
-      "version": "1.4.1",
+      "version": "1.5.0",
       "requires": {
+        "object-assign": "^4.1.1",
         "util": "0.10.3"
+      },
+      "dependencies": {
+        "inherits": {
+          "version": "2.0.1",
+        },
+        "util": {
+          "version": "0.10.3",
+          "requires": {
+            "inherits": "2.0.1"
+          }
+        }
       }
     },
     "assign-symbols": {
@@ -627,15 +645,6 @@
     },
-    "astw": {
-      "version": "2.2.0",
-      "requires": {
-        "acorn": "^4.0.3"
-      }
-    },
     "async": {
       "version": "2.6.1",
@@ -761,9 +770,9 @@
       }
     },
     "base64-js": {
-      "version": "1.2.1",
+      "version": "1.3.1",
     },
     "binary-extensions": {
@@ -881,9 +890,9 @@
     },
     "browser-resolve": {
-      "version": "1.11.2",
+      "version": "1.11.3",
       "requires": {
         "resolve": "1.1.7"
@@ -904,9 +913,9 @@
     },
     "browserify": {
-      "version": "16.2.3",
+      "version": "16.3.0",
       "requires": {
         "JSONStream": "^1.0.3",
@@ -971,13 +980,19 @@
             "typedarray": "^0.0.6"
           }
         },
+        "safe-buffer": {
+          "version": "5.2.0",
+        },
         "string_decoder": {
-          "version": "1.1.1",
+          "version": "1.3.0",
           "requires": {
-            "safe-buffer": "~5.1.0"
+            "safe-buffer": "~5.2.0"
           }
         }
       }
@@ -1064,9 +1079,9 @@
       }
     },
     "buffer": {
-      "version": "5.0.7",
+      "version": "5.2.1",
       "requires": {
         "base64-js": "^1.0.2",
@@ -1690,6 +1705,12 @@
         "randombytes": "^2.0.0"
       }
     },
+    "dash-ast": {
+      "version": "1.0.0",
+    },
     "date-fns": {
       "version": "1.29.0",
@@ -3332,6 +3353,12 @@
         }
       }
     },
+    "get-assigned-identifiers": {
+      "version": "1.2.0",
+    },
     "get-caller-file": {
       "version": "2.0.5",
@@ -3652,9 +3679,9 @@
     },
     "ieee754": {
-      "version": "1.1.8",
+      "version": "1.1.13",
     },
     "ignore": {
@@ -3793,19 +3820,47 @@
       }
     },
     "insert-module-globals": {
-      "version": "7.0.1",
+      "version": "7.2.0",
       "requires": {
         "JSONStream": "^1.0.3",
-        "combine-source-map": "~0.7.1",
-        "concat-stream": "~1.5.1",
+        "acorn-node": "^1.5.2",
+        "combine-source-map": "^0.8.0",
+        "concat-stream": "^1.6.1",
         "is-buffer": "^1.1.0",
-        "lexical-scope": "^1.2.0",
+        "path-is-absolute": "^1.0.1",
         "process": "~0.11.0",
         "through2": "^2.0.0",
+        "undeclared-identifiers": "^1.1.2",
         "xtend": "^4.0.0"
+      },
+      "dependencies": {
+        "combine-source-map": {
+          "version": "0.8.0",
+          "requires": {
+            "convert-source-map": "~1.1.0",
+            "inline-source-map": "~0.6.0",
+            "lodash.memoize": "~3.0.3",
+            "source-map": "~0.5.3"
+          }
+        },
+        "concat-stream": {
+          "version": "1.6.2",
+          "requires": {
+            "buffer-from": "^1.0.0",
+            "inherits": "^2.0.3",
+            "readable-stream": "^2.2.2",
+            "typedarray": "^0.0.6"
+          }
+        }
       }
     },
     "invert-kv": {
@@ -4343,13 +4398,12 @@
       }
     },
     "labeled-stream-splicer": {
-      "version": "2.0.0",
+      "version": "2.0.2",
       "requires": {
         "inherits": "^2.0.1",
-        "isarray": "~0.0.1",
         "stream-splicer": "^2.0.0"
       }
     },
@@ -4592,15 +4646,6 @@
         "type-check": "~0.3.2"
       }
     },
-    "lexical-scope": {
-      "version": "1.2.0",
-      "requires": {
-        "astw": "^2.0.0"
-      }
-    },
     "linkify-it": {
       "version": "2.0.3",
@@ -5768,14 +5813,14 @@
       }
     },
     "module-deps": {
-      "version": "6.2.0",
+      "version": "6.2.1",
       "requires": {
         "JSONStream": "^1.0.3",
         "browser-resolve": "^1.7.0",
-        "cached-path-relative": "^1.0.0",
+        "cached-path-relative": "^1.0.2",
         "concat-stream": "~1.6.0",
         "defined": "^1.0.0",
         "detective": "^5.0.2",
@@ -5803,12 +5848,12 @@
           }
         },
         "detective": {
-          "version": "5.1.0",
+          "version": "5.2.0",
           "requires": {
-            "acorn-node": "^1.3.0",
+            "acorn-node": "^1.6.1",
             "defined": "^1.0.0",
             "minimist": "^1.1.1"
           }
@@ -6607,9 +6652,9 @@
       }
     },
     "pako": {
-      "version": "1.0.6",
+      "version": "1.0.10",
     },
     "parent-module": {
@@ -6666,9 +6711,9 @@
     },
     "path-browserify": {
-      "version": "0.0.0",
+      "version": "0.0.1",
     },
     "path-dirname": {
@@ -8221,6 +8266,12 @@
     },
+    "simple-concat": {
+      "version": "1.0.0",
+    },
     "slash": {
       "version": "1.0.0",
@@ -8509,9 +8560,9 @@
       }
     },
     "stream-browserify": {
-      "version": "2.0.1",
+      "version": "2.0.2",
       "requires": {
         "inherits": "~2.0.1",
@@ -8529,22 +8580,60 @@
       }
     },
     "stream-http": {
-      "version": "2.7.2",
+      "version": "2.8.3",
       "requires": {
         "builtin-status-codes": "^3.0.0",
         "inherits": "^2.0.1",
-        "readable-stream": "^2.2.6",
+        "readable-stream": "^2.3.6",
         "to-arraybuffer": "^1.0.0",
         "xtend": "^4.0.0"
+      },
+      "dependencies": {
+        "isarray": {
+          "version": "1.0.0",
+        },
+        "process-nextick-args": {
+          "version": "2.0.1",
+        },
+        "readable-stream": {
+          "version": "2.3.6",
+          "requires": {
+            "core-util-is": "~1.0.0",
+            "inherits": "~2.0.3",
+            "isarray": "~1.0.0",
+            "process-nextick-args": "~2.0.0",
+            "safe-buffer": "~5.1.1",
+            "string_decoder": "~1.1.1",
+            "util-deprecate": "~1.0.1"
+          }
+        },
+        "string_decoder": {
+          "version": "1.1.1",
+          "requires": {
+            "safe-buffer": "~5.1.0"
+          }
+        }
       }
     },
     "stream-splicer": {
-      "version": "2.0.0",
+      "version": "2.0.1",
       "requires": {
         "inherits": "^2.0.1",
@@ -8679,12 +8768,12 @@
     },
     "syntax-error": {
-      "version": "1.3.0",
+      "version": "1.4.0",
       "requires": {
-        "acorn": "^4.0.3"
+        "acorn-node": "^1.2.0"
       }
     },
     "table": {
@@ -8987,6 +9076,19 @@
     },
+    "undeclared-identifiers": {
+      "version": "1.1.3",
+      "requires": {
+        "acorn-node": "^1.3.0",
+        "dash-ast": "^1.0.0",
+        "get-assigned-identifiers": "^1.2.0",
+        "simple-concat": "^1.0.0",
+        "xtend": "^4.0.1"
+      }
+    },
     "union-value": {
       "version": "1.0.1",
@@ -9105,20 +9207,12 @@
     },
     "util": {
-      "version": "0.10.3",
+      "version": "0.10.4",
       "requires": {
-        "inherits": "2.0.1"
-      },
-      "dependencies": {
-        "inherits": {
-          "version": "2.0.1",
-        }
+        "inherits": "2.0.3"
       }
     },
     "util-deprecate": {

Wondering if this could be related (mentions sinon and lolex fake timers):
https://github.com/calvinmetcalf/process-nextick-args/commit/108596de940c73e78e0378a4084ab73ac846aed0

It looks like a bug in process-nextick-args was fixed. Do you want to try again?

Nothing has happened in that project for more than a year, so it should still fail. We could update all other packages, but this would remain a blocker for updating browserify.

As this bug manifested itself in the fake timers code, I assumed the bug was in Lolex, but alas, it turns out adding the same tests to lolex and upgrading Browserify (=>Chokidar=>fsevents=>process-nextick-args) does _not_ manifest the bug. The same process-nextick-args version (2.0.0) was there (in Lolex), as well. Which points to this being the little code that is specific to Sinon's own fake-timers.js. My guess in on the module.exports code.

For the output below, I added some console output:

$ git diff test/
diff --git a/test/util/fake-timers-test.js b/test/util/fake-timers-test.js
index 97965647..27944a18 100644
--- a/test/util/fake-timers-test.js
+++ b/test/util/fake-timers-test.js
@@ -1068,10 +1068,15 @@ describe("fakeTimers.clock", function() {
         });

         it("fakes provided methods", function() {
+            console.log("setImmediate", setImmediate);
+            console.log("fakeTimers.timers.setImmediate", fakeTimers.timers.setImmediate);
             this.clock = fakeTimers.useFakeTimers({ toFake: ["setTimeout", "Date", "setImmediate"] });

             refute.same(setTimeout, fakeTimers.timers.setTimeout);
             refute.same(Date, fakeTimers.timers.Date);
+            console.log("setImmediate", setImmediate);
+            console.log("fakeTimers.timers.setImmediate", fakeTimers.timers.setImmediate);
             refute.same(setImmediate, fakeTimers.timers.setImmediate);
         });


Output before upgrading Browserify/process-nextick-args

# chromium:


  fakeTimers.clock
...
    .setImmediate
      βœ“ returns numeric id or object with numeric id
      βœ“ calls the given callback immediately
      βœ“ throws if no arguments
      βœ“ manages separate timers per clock instance
      βœ“ passes extra parameters through to the callback
    .clearImmediate
      βœ“ removes immediate callbacks
    .tick
      βœ“ triggers immediately without specified delay
      βœ“ does not trigger without sufficient delay
      βœ“ triggers after sufficient delay
      βœ“ triggers simultaneous timers
      βœ“ triggers multiple simultaneous timers
      βœ“ triggers multiple simultaneous timers with zero callAt
      βœ“ waits after setTimeout was called
      βœ“ mini integration test
      βœ“ triggers even when some throw
      βœ“ calls function with global object or null (strict mode) as this
      βœ“ triggers in the order scheduled
      βœ“ creates updated Date while ticking
      βœ“ fires timer in intervals of 13
      βœ“ fires timers in correct order
      βœ“ triggers timeouts and intervals in the order scheduled
      βœ“ does not fire canceled intervals
      βœ“ passes 6 seconds
      βœ“ passes 1 minute
      βœ“ passes 2 hours, 34 minutes and 12 seconds (63ms)
      βœ“ throws for invalid format
      βœ“ throws for invalid minutes
      βœ“ throws for negative minutes
      βœ“ treats missing argument as 0
      βœ“ fires nested setTimeout calls properly
      βœ“ does not silently catch exceptions
      βœ“ returns the current now value
    .useFakeTimers
      βœ“ returns clock object
      βœ“ has clock property
      βœ“ sets initial timestamp
      βœ“ replaces global setTimeout
      βœ“ global fake setTimeout should return id
      βœ“ replaces global clearTimeout
      βœ“ restores global setTimeout
      βœ“ restores global clearTimeout
      βœ“ replaces global setInterval
      βœ“ replaces global clearInterval
      βœ“ restores global setInterval
      βœ“ restores global clearInterval
      βœ“ deletes global property on restore if it was inherited onto the global object
      βœ“ restores global property on restore if it is present on the global object itself
      βœ“ fakes Date constructor
      βœ“ fake Date constructor should mirror Date's properties
      βœ“ decide on Date.now support at call-time when supported
      βœ“ decide on Date.now support at call-time when unsupported
      βœ“ mirrors custom Date properties
      βœ“ restores Date constructor
setImmediate undefined
fakeTimers.timers.setImmediate undefined
setImmediate function () {
                return clock[method].apply(clock, arguments);
            }
fakeTimers.timers.setImmediate undefined
      βœ“ fakes provided methods

Interesting bits: setImmediate is undefined before running the test, but the test runs.


Output before upgrading Browserify/process-nextick-args, but just running the single test

$ mochify test/util/fake-timers-test.js --grep "fakes provided methods"  > output_pre.txt

# chromium:


  fakeTimers.clock
    .useFakeTimers
      1) fakes provided methods


  0 passing (32ms)
  1 failing

  1) fakeTimers.clock
       .useFakeTimers
         fakes provided methods:
     ReferenceError: setImmediate is not defined
      at Context.<anonymous> (test/util/fake-timers-test.js:1072)

Interesting: We get an error saying setImmediate is not defined in this single run, meaning that when we run the entire test suite we add a global that was not there (even if we set it to undefined). That means the test affects the global scope. This might be crucial in understanding why we suddenly have a setImmediate implementation after upgrading process-nextick-args. Maybe it somehow checks if the variable is defined (different from undefined).


Output after upgrading Browserify/process-nextick-args (single test run)

$ cat output_post.txt 
# chromium:


  fakeTimers.clock
    .useFakeTimers
setImmediate function(fn) {
  var id = nextImmediateId++;
  var args = arguments.length < 2 ? false : slice.call(arguments, 1);

  immediateIds[id] = true;

  nextTick(function onNextTick() {
    if (immediateIds[id]) {
      // fn.call() is faster so we optimize for the common use-case
      // @see http://jsperf.com/call-apply-segu
      if (args) {
        fn.apply(null, args);
      } else {
        fn.call(null);
      }
      // Prevent ids from leaking
      exports.clearImmediate(id);
    }
  });

  return id;
}
fakeTimers.timers.setImmediate function(fn) {
  var id = nextImmediateId++;
  var args = arguments.length < 2 ? false : slice.call(arguments, 1);

  immediateIds[id] = true;

  nextTick(function onNextTick() {
    if (immediateIds[id]) {
      // fn.call() is faster so we optimize for the common use-case
      // @see http://jsperf.com/call-apply-segu
      if (args) {
        fn.apply(null, args);
      } else {
        fn.call(null);
      }
      // Prevent ids from leaking
      exports.clearImmediate(id);
    }
  });

  return id;
}
setImmediate function(fn) {
  var id = nextImmediateId++;
  var args = arguments.length < 2 ? false : slice.call(arguments, 1);

  immediateIds[id] = true;

  nextTick(function onNextTick() {
    if (immediateIds[id]) {
      // fn.call() is faster so we optimize for the common use-case
      // @see http://jsperf.com/call-apply-segu
      if (args) {
        fn.apply(null, args);
      } else {
        fn.call(null);
      }
      // Prevent ids from leaking
      exports.clearImmediate(id);
    }
  });

  return id;
}
fakeTimers.timers.setImmediate function(fn) {
  var id = nextImmediateId++;
  var args = arguments.length < 2 ? false : slice.call(arguments, 1);

  immediateIds[id] = true;

  nextTick(function onNextTick() {
    if (immediateIds[id]) {
      // fn.call() is faster so we optimize for the common use-case
      // @see http://jsperf.com/call-apply-segu
      if (args) {
        fn.apply(null, args);
      } else {
        fn.call(null);
      }
      // Prevent ids from leaking
      exports.clearImmediate(id);
    }
  });

  return id;
}
      1) fakes provided methods


  0 passing (79ms)
  1 failing

  1) fakeTimers.clock
       .useFakeTimers
         fakes provided methods:
     AssertionError: [refute.same] function onNextTick() {} expected not to be the same object as function onNextTick() {}
      at Object.fail (node_modules/@sinonjs/referee/lib/create-fail.js:5)
      at Object.fail (node_modules/@sinonjs/referee/lib/define-assertion.js:46)
      at assertion (node_modules/@sinonjs/referee/lib/define-assertion.js:68)
      at Function.referee.<computed>.<computed> [as same] (node_modules/@sinonjs/referee/lib/define-assertion.js:93)
      at Context.<anonymous> (test/util/fake-timers-test.js:1080)

The interesting bit here is that

  • setImmediate is defined as a (user defined) function before the test
  • the value of setImmediate _does not change_ during the test

Updating to Browserify 16.3 is not needed. It suffices to just do npm install [email protected] and it will update all the deps for that version, and that shows the same bug.

This is the diff in package-lock.json

git diff package-lock.json

diff --git a/package-lock.json b/package-lock.json
index c2290730..92060702 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -403,12 +403,6 @@
       "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=",
       "dev": true
     },
-    "acorn-dynamic-import": {
-      "version": "4.0.0",
-      "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz",
-      "integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==",
-      "dev": true
-    },
     "acorn-jsx": {
       "version": "5.0.2",
       "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.2.tgz",
@@ -416,29 +410,34 @@
       "dev": true
     },
     "acorn-node": {
-      "version": "1.6.2",
-      "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.6.2.tgz",
-      "integrity": "sha512-rIhNEZuNI8ibQcL7ANm/mGyPukIaZsRNX9psFNQURyJW0nu6k8wjSDld20z6v2mDBWqX13pIEnk9gGZJHIlEXg==",
+      "version": "1.8.2",
+      "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.8.2.tgz",
+      "integrity": "sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A==",
       "dev": true,
       "requires": {
-        "acorn": "^6.0.2",
-        "acorn-dynamic-import": "^4.0.0",
-        "acorn-walk": "^6.1.0",
-        "xtend": "^4.0.1"
+        "acorn": "^7.0.0",
+        "acorn-walk": "^7.0.0",
+        "xtend": "^4.0.2"
       },
       "dependencies": {
         "acorn": {
-          "version": "6.0.4",
-          "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.4.tgz",
-          "integrity": "sha512-VY4i5EKSKkofY2I+6QLTbTTN/UvEQPCo6eiwzzSaSWfpaDhOmStMCMod6wmuPciNq+XS0faCglFu2lHZpdHUtg==",
+          "version": "7.0.0",
+          "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.0.0.tgz",
+          "integrity": "sha512-PaF/MduxijYYt7unVGRuds1vBC9bFxbNf+VWqhOClfdgy7RlVkQqt610ig1/yxTgsDIfW1cWDel5EBbOy3jdtQ==",
+          "dev": true
+        },
+        "xtend": {
+          "version": "4.0.2",
+          "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
+          "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
           "dev": true
         }
       }
     },
     "acorn-walk": {
-      "version": "6.1.1",
-      "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.1.1.tgz",
-      "integrity": "sha512-OtUw6JUTgxA2QoqqmrmQ7F2NYqiBPi/L2jqHyFtllhOUvXYQXf0Z1CYUinIfyT4bTCGmrA7gX9FvHA81uzCoVw==",
+      "version": "7.0.0",
+      "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.0.0.tgz",
+      "integrity": "sha512-7Bv1We7ZGuU79zZbb6rRqcpxo3OY+zrdtloZWoyD8fmGX+FeXRjE+iuGkZjSXLVovLzrsvMGMy0EkwA0E0umxg==",
       "dev": true
     },
     "agent-base": {
@@ -614,12 +613,30 @@
       }
     },
     "assert": {
-      "version": "1.4.1",
-      "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz",
-      "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=",
+      "version": "1.5.0",
+      "resolved": "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz",
+      "integrity": "sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==",
       "dev": true,
       "requires": {
+        "object-assign": "^4.1.1",
         "util": "0.10.3"
+      },
+      "dependencies": {
+        "inherits": {
+          "version": "2.0.1",
+          "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz",
+          "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=",
+          "dev": true
+        },
+        "util": {
+          "version": "0.10.3",
+          "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
+          "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
+          "dev": true,
+          "requires": {
+            "inherits": "2.0.1"
+          }
+        }
       }
     },
     "assign-symbols": {
@@ -634,15 +651,6 @@
       "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==",
       "dev": true
     },
-    "astw": {
-      "version": "2.2.0",
-      "resolved": "https://registry.npmjs.org/astw/-/astw-2.2.0.tgz",
-      "integrity": "sha1-e9QXhNMkk5h66yOba04cV6hzuRc=",
-      "dev": true,
-      "requires": {
-        "acorn": "^4.0.3"
-      }
-    },
     "async": {
       "version": "2.6.1",
       "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz",
@@ -768,9 +776,9 @@
       }
     },
     "base64-js": {
-      "version": "1.2.1",
-      "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz",
-      "integrity": "sha1-qRlH2h9KUW6jjltOwOw3c2deCIY=",
+      "version": "1.3.1",
+      "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz",
+      "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==",
       "dev": true
     },
     "binary-extensions": {
@@ -888,9 +896,9 @@
       "dev": true
     },
     "browser-resolve": {
-      "version": "1.11.2",
-      "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.2.tgz",
-      "integrity": "sha1-j/CbCixCFxihBRwmCzLkj0QpOM4=",
+      "version": "1.11.3",
+      "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz",
+      "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==",
       "dev": true,
       "requires": {
         "resolve": "1.1.7"
@@ -978,13 +986,19 @@
             "typedarray": "^0.0.6"
           }
         },
+        "safe-buffer": {
+          "version": "5.2.0",
+          "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz",
+          "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==",
+          "dev": true
+        },
         "string_decoder": {
-          "version": "1.1.1",
-          "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
-          "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
+          "version": "1.3.0",
+          "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
+          "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
           "dev": true,
           "requires": {
-            "safe-buffer": "~5.1.0"
+            "safe-buffer": "~5.2.0"
           }
         }
       }
@@ -1071,9 +1085,9 @@
       }
     },
     "buffer": {
-      "version": "5.0.7",
-      "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.0.7.tgz",
-      "integrity": "sha512-NeeHXWh5pCbPQCt2/6rLvXqapZfVsqw/YgRgaHpT3H9Uzgs+S0lSg5SQzouIuDvcmlQRqBe8hOO2scKCu3cxrg==",
+      "version": "5.4.3",
+      "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.4.3.tgz",
+      "integrity": "sha512-zvj65TkFeIt3i6aj5bIvJDzjjQQGs4o/sNoezg1F1kYap9Nu2jcUdpwzRSJTHMMzG0H7bZkn4rNQpImhuxWX2A==",
       "dev": true,
       "requires": {
         "base64-js": "^1.0.2",
@@ -1697,6 +1711,12 @@
         "randombytes": "^2.0.0"
       }
     },
+    "dash-ast": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/dash-ast/-/dash-ast-1.0.0.tgz",
+      "integrity": "sha512-Vy4dx7gquTeMcQR/hDkYLGUnwVil6vk4FOOct+djUnHOUWt+zJPJAaRIXaAFkPXtJjvlY7o3rfRu0/3hpnwoUA==",
+      "dev": true
+    },
     "date-fns": {
       "version": "1.29.0",
       "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-1.29.0.tgz",
@@ -3392,6 +3412,12 @@
         }
       }
     },
+    "get-assigned-identifiers": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz",
+      "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==",
+      "dev": true
+    },
     "get-caller-file": {
       "version": "2.0.5",
       "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
@@ -3712,9 +3738,9 @@
       "dev": true
     },
     "ieee754": {
-      "version": "1.1.8",
-      "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz",
-      "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=",
+      "version": "1.1.13",
+      "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz",
+      "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==",
       "dev": true
     },
     "ignore": {
@@ -3853,19 +3879,47 @@
       }
     },
     "insert-module-globals": {
-      "version": "7.0.1",
-      "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.0.1.tgz",
-      "integrity": "sha1-wDv04BywhtW15azorQr+eInWOMM=",
+      "version": "7.2.0",
+      "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.0.tgz",
+      "integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==",
       "dev": true,
       "requires": {
         "JSONStream": "^1.0.3",
-        "combine-source-map": "~0.7.1",
-        "concat-stream": "~1.5.1",
+        "acorn-node": "^1.5.2",
+        "combine-source-map": "^0.8.0",
+        "concat-stream": "^1.6.1",
         "is-buffer": "^1.1.0",
-        "lexical-scope": "^1.2.0",
+        "path-is-absolute": "^1.0.1",
         "process": "~0.11.0",
         "through2": "^2.0.0",
+        "undeclared-identifiers": "^1.1.2",
         "xtend": "^4.0.0"
+      },
+      "dependencies": {
+        "combine-source-map": {
+          "version": "0.8.0",
+          "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz",
+          "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=",
+          "dev": true,
+          "requires": {
+            "convert-source-map": "~1.1.0",
+            "inline-source-map": "~0.6.0",
+            "lodash.memoize": "~3.0.3",
+            "source-map": "~0.5.3"
+          }
+        },
+        "concat-stream": {
+          "version": "1.6.2",
+          "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
+          "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
+          "dev": true,
+          "requires": {
+            "buffer-from": "^1.0.0",
+            "inherits": "^2.0.3",
+            "readable-stream": "^2.2.2",
+            "typedarray": "^0.0.6"
+          }
+        }
       }
     },
     "invert-kv": {
@@ -4403,13 +4457,12 @@
       }
     },
     "labeled-stream-splicer": {
-      "version": "2.0.0",
-      "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.0.tgz",
-      "integrity": "sha1-pS4dE4AkwAuGscDJH2d5GLiuClk=",
+      "version": "2.0.2",
+      "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.2.tgz",
+      "integrity": "sha512-Ca4LSXFFZUjPScRaqOcFxneA0VpKZr4MMYCljyQr4LIewTLb3Y0IUTIsnBBsVubIeEfxeSZpSjSsRM8APEQaAw==",
       "dev": true,
       "requires": {
         "inherits": "^2.0.1",
-        "isarray": "~0.0.1",
         "stream-splicer": "^2.0.0"
       }
     },
@@ -4652,15 +4705,6 @@
         "type-check": "~0.3.2"
       }
     },
-    "lexical-scope": {
-      "version": "1.2.0",
-      "resolved": "https://registry.npmjs.org/lexical-scope/-/lexical-scope-1.2.0.tgz",
-      "integrity": "sha1-/Ope3HBKSzqHls3KQZw6CvryLfQ=",
-      "dev": true,
-      "requires": {
-        "astw": "^2.0.0"
-      }
-    },
     "linkify-it": {
       "version": "2.0.3",
       "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.0.3.tgz",
@@ -5829,14 +5873,14 @@
       }
     },
     "module-deps": {
-      "version": "6.2.0",
-      "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.2.0.tgz",
-      "integrity": "sha512-hKPmO06so6bL/ZvqVNVqdTVO8UAYsi3tQWlCa+z9KuWhoN4KDQtb5hcqQQv58qYiDE21wIvnttZEPiDgEbpwbA==",
+      "version": "6.2.1",
+      "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.2.1.tgz",
+      "integrity": "sha512-UnEn6Ah36Tu4jFiBbJVUtt0h+iXqxpLqDvPS8nllbw5RZFmNJ1+Mz5BjYnM9ieH80zyxHkARGLnMIHlPK5bu6A==",
       "dev": true,
       "requires": {
         "JSONStream": "^1.0.3",
         "browser-resolve": "^1.7.0",
-        "cached-path-relative": "^1.0.0",
+        "cached-path-relative": "^1.0.2",
         "concat-stream": "~1.6.0",
         "defined": "^1.0.0",
         "detective": "^5.0.2",
@@ -5864,12 +5908,12 @@
           }
         },
         "detective": {
-          "version": "5.1.0",
-          "resolved": "https://registry.npmjs.org/detective/-/detective-5.1.0.tgz",
-          "integrity": "sha512-TFHMqfOvxlgrfVzTEkNBSh9SvSNX/HfF4OFI2QFGCyPm02EsyILqnUeb5P6q7JZ3SFNTBL5t2sePRgrN4epUWQ==",
+          "version": "5.2.0",
+          "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.0.tgz",
+          "integrity": "sha512-6SsIx+nUUbuK0EthKjv0zrdnajCCXVYGmbYYiYjFVpzcjwEs/JMDZ8tPRG29J/HhN56t3GJp2cGSWDRjjot8Pg==",
           "dev": true,
           "requires": {
-            "acorn-node": "^1.3.0",
+            "acorn-node": "^1.6.1",
             "defined": "^1.0.0",
             "minimist": "^1.1.1"
           }
@@ -6668,9 +6712,9 @@
       }
     },
     "pako": {
-      "version": "1.0.6",
-      "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz",
-      "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==",
+      "version": "1.0.10",
+      "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.10.tgz",
+      "integrity": "sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw==",
       "dev": true
     },
     "parent-module": {
@@ -6727,9 +6771,9 @@
       "dev": true
     },
     "path-browserify": {
-      "version": "0.0.0",
-      "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz",
-      "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=",
+      "version": "0.0.1",
+      "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz",
+      "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==",
       "dev": true
     },
     "path-dirname": {
@@ -8282,6 +8326,12 @@
       "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=",
       "dev": true
     },
+    "simple-concat": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz",
+      "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=",
+      "dev": true
+    },
     "slash": {
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz",
@@ -8570,9 +8620,9 @@
       }
     },
     "stream-browserify": {
-      "version": "2.0.1",
-      "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz",
-      "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=",
+      "version": "2.0.2",
+      "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz",
+      "integrity": "sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg==",
       "dev": true,
       "requires": {
         "inherits": "~2.0.1",
@@ -8590,22 +8640,60 @@
       }
     },
     "stream-http": {
-      "version": "2.7.2",
-      "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.7.2.tgz",
-      "integrity": "sha512-c0yTD2rbQzXtSsFSVhtpvY/vS6u066PcXOX9kBB3mSO76RiUQzL340uJkGBWnlBg4/HZzqiUXtaVA7wcRcJgEw==",
+      "version": "2.8.3",
+      "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.3.tgz",
+      "integrity": "sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==",
       "dev": true,
       "requires": {
         "builtin-status-codes": "^3.0.0",
         "inherits": "^2.0.1",
-        "readable-stream": "^2.2.6",
+        "readable-stream": "^2.3.6",
         "to-arraybuffer": "^1.0.0",
         "xtend": "^4.0.0"
+      },
+      "dependencies": {
+        "isarray": {
+          "version": "1.0.0",
+          "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
+          "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
+          "dev": true
+        },
+        "process-nextick-args": {
+          "version": "2.0.1",
+          "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
+          "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
+          "dev": true
+        },
+        "readable-stream": {
+          "version": "2.3.6",
+          "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
+          "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
+          "dev": true,
+          "requires": {
+            "core-util-is": "~1.0.0",
+            "inherits": "~2.0.3",
+            "isarray": "~1.0.0",
+            "process-nextick-args": "~2.0.0",
+            "safe-buffer": "~5.1.1",
+            "string_decoder": "~1.1.1",
+            "util-deprecate": "~1.0.1"
+          }
+        },
+        "string_decoder": {
+          "version": "1.1.1",
+          "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
+          "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
+          "dev": true,
+          "requires": {
+            "safe-buffer": "~5.1.0"
+          }
+        }
       }
     },
     "stream-splicer": {
-      "version": "2.0.0",
-      "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.0.tgz",
-      "integrity": "sha1-G2O+Q4oTPktnHMGTUZdgAXWRDYM=",
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.1.tgz",
+      "integrity": "sha512-Xizh4/NPuYSyAXyT7g8IvdJ9HJpxIGL9PjyhtywCZvvP0OPIdqyrr4dMikeuvY8xahpdKEBlBTySe583totajg==",
       "dev": true,
       "requires": {
         "inherits": "^2.0.1",
@@ -8740,12 +8828,12 @@
       "dev": true
     },
     "syntax-error": {
-      "version": "1.3.0",
-      "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.3.0.tgz",
-      "integrity": "sha1-HtkmbE1AvnXcVb+bsct3Biu5bKE=",
+      "version": "1.4.0",
+      "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz",
+      "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==",
       "dev": true,
       "requires": {
-        "acorn": "^4.0.3"
+        "acorn-node": "^1.2.0"
       }
     },
     "table": {
@@ -9048,6 +9136,19 @@
       "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=",
       "dev": true
     },
+    "undeclared-identifiers": {
+      "version": "1.1.3",
+      "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.3.tgz",
+      "integrity": "sha512-pJOW4nxjlmfwKApE4zvxLScM/njmwj/DiUBv7EabwE4O8kRUy+HIwxQtZLBPll/jx1LJyBcqNfB3/cpv9EZwOw==",
+      "dev": true,
+      "requires": {
+        "acorn-node": "^1.3.0",
+        "dash-ast": "^1.0.0",
+        "get-assigned-identifiers": "^1.2.0",
+        "simple-concat": "^1.0.0",
+        "xtend": "^4.0.1"
+      }
+    },
     "union-value": {
       "version": "1.0.1",
       "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
@@ -9166,20 +9267,12 @@
       "dev": true
     },
     "util": {
-      "version": "0.10.3",
-      "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
-      "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
+      "version": "0.10.4",
+      "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
+      "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
       "dev": true,
       "requires": {
-        "inherits": "2.0.1"
-      },
-      "dependencies": {
-        "inherits": {
-          "version": "2.0.1",
-          "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz",
-          "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=",
-          "dev": true
-        }
+        "inherits": "2.0.3"
       }
     },
     "util-deprecate": {

Maybe it could be used to find the guilty suspect in node_modules:

grep -rl setImmediate node_modules/

node_modules/inquirer/node_modules/rxjs/_esm2015/internal/util/Immediate.js
node_modules/inquirer/node_modules/rxjs/_esm2015/internal/scheduler/AsapAction.js
node_modules/inquirer/node_modules/rxjs/src/internal/util/Immediate.ts
node_modules/inquirer/node_modules/rxjs/src/internal/scheduler/AsapAction.ts
node_modules/inquirer/node_modules/rxjs/internal/util/Immediate.js
node_modules/inquirer/node_modules/rxjs/internal/util/Immediate.d.ts
node_modules/inquirer/node_modules/rxjs/internal/scheduler/AsapAction.js
node_modules/inquirer/node_modules/rxjs/_esm5/internal/util/Immediate.js
node_modules/inquirer/node_modules/rxjs/_esm5/internal/scheduler/AsapAction.js
node_modules/inquirer/node_modules/rxjs/bundles/rxjs.umd.min.js
node_modules/inquirer/node_modules/rxjs/bundles/rxjs.umd.js
node_modules/inquirer/node_modules/rxjs/bundles/rxjs.umd.js.map
node_modules/inquirer/node_modules/rxjs/bundles/rxjs.umd.min.js.map
node_modules/@types/node/index.d.ts
node_modules/@types/node/README.md
node_modules/@sinonjs/samsam/node_modules/lodash/lodash.js
node_modules/uglify-js/tools/domprops.json
node_modules/uglify-js/tools/exit.js
node_modules/mochify/node_modules/mocha/mocha.js
node_modules/mochify/node_modules/mocha/CHANGELOG.md
node_modules/mochify/node_modules/mocha/lib/runner.js
node_modules/mochify/lib/mochify.js
node_modules/readable-stream/lib/_stream_writable.js
node_modules/stream-splicer/index.js
node_modules/levelup/CHANGELOG.md
node_modules/levelup/lib/write-stream.js
node_modules/external-editor/main/index.js
node_modules/rxjs/util/Immediate.js.map
node_modules/rxjs/util/Immediate.js
node_modules/rxjs/util/Immediate.d.ts
node_modules/rxjs/_esm2015/util/Immediate.js
node_modules/rxjs/_esm2015/scheduler/AsapAction.js
node_modules/rxjs/scheduler/AsapAction.js.map
node_modules/rxjs/scheduler/AsapAction.js
node_modules/rxjs/src/util/Immediate.ts
node_modules/rxjs/src/scheduler/AsapAction.ts
node_modules/rxjs/_esm5/util/Immediate.js
node_modules/rxjs/_esm5/scheduler/AsapAction.js
node_modules/rxjs/bundles/Rx.js.map
node_modules/rxjs/bundles/Rx.min.js
node_modules/rxjs/bundles/Rx.js
node_modules/rxjs/bundles/Rx.min.js.map
node_modules/native-promise-only/npo.js
node_modules/native-promise-only/lib/npo.src.js
node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js
node_modules/es6-promise/CHANGELOG.md
node_modules/path-type/node_modules/pify/readme.md
node_modules/globals/globals.json
node_modules/timers-browserify/CHANGELOG.md
node_modules/timers-browserify/README.md
node_modules/timers-browserify/main.js
node_modules/neo-async/async.js
node_modules/neo-async/README.md
node_modules/neo-async/async.min.js
node_modules/neo-async/setImmediate.js
node_modules/readdirp/stream-api.js
node_modules/readdirp/readdirp.js
node_modules/level-blobs/node_modules/readable-stream/float.patch
node_modules/transformify/node_modules/readable-stream/float.patch
node_modules/mocha/mocha.js
node_modules/mocha/CHANGELOG.md
node_modules/mocha/lib/runner.js
node_modules/mocaccino/node_modules/readable-stream/lib/_stream_writable.js
node_modules/mocaccino/node_modules/mocha/mocha.js
node_modules/mocaccino/node_modules/mocha/CHANGELOG.md
node_modules/mocaccino/node_modules/mocha/lib/runner.js
node_modules/esm/esm/loader.js
node_modules/puppeteer/.local-chromium/linux-674921/chrome-linux/resources/inspector/toolbox.js
node_modules/puppeteer/.local-chromium/linux-674921/chrome-linux/resources/inspector/devtools_compatibility.js
node_modules/puppeteer/.local-chromium/linux-674921/chrome-linux/resources/inspector/console/console_module.js
node_modules/puppeteer/.local-chromium/linux-674921/chrome-linux/resources/inspector/heap_snapshot_worker.js
node_modules/puppeteer/.local-chromium/linux-674921/chrome-linux/resources/inspector/text_editor/text_editor_module.js
node_modules/puppeteer/.local-chromium/linux-674921/chrome-linux/resources/inspector/audits_worker/audits_worker_module.js
node_modules/puppeteer/.local-chromium/linux-674921/chrome-linux/resources/inspector/network/network_module.js
node_modules/puppeteer/.local-chromium/linux-674921/chrome-linux/resources/inspector/formatter_worker.js
node_modules/puppeteer/.local-chromium/linux-674921/chrome-linux/resources/inspector/sources/sources_module.js
node_modules/puppeteer/.local-chromium/linux-674921/chrome-linux/resources/inspector/shell.js
node_modules/puppeteer/.local-chromium/linux-674921/chrome-linux/resources.pak
node_modules/load-json-file/node_modules/pify/readme.md
node_modules/async/memoize.js
node_modules/async/wrapSync.js
node_modules/async/nextTick.js
node_modules/async/CHANGELOG.md
node_modules/async/asyncify.js
node_modules/async/dist/async.min.map
node_modules/async/dist/async.js
node_modules/async/dist/async.min.js
node_modules/async/internal/queue.js
node_modules/async/internal/setImmediate.js
node_modules/async/transform.js
node_modules/async/priorityQueue.js
node_modules/async/index.js
node_modules/async/setImmediate.js
node_modules/async/ensureAsync.js
node_modules/lodash/lodash.js
node_modules/stream-http/node_modules/readable-stream/lib/_stream_writable.js
node_modules/lolex/lolex.js
node_modules/lolex/CHANGELOG.md
node_modules/lolex/src/lolex-src.js
node_modules/lolex/README.md
node_modules/prettier/bin-prettier.js
node_modules/prettier/index.js
node_modules/insert-module-globals/readme.markdown
node_modules/insert-module-globals/index.js
node_modules/insert-module-globals/test/immediate/main.js
node_modules/rollup-plugin-node-builtins/src/es6/timers.js
node_modules/rollup-plugin-node-builtins/src/es6/setimmediate.js
node_modules/lint-staged/node_modules/pify/readme.md
node_modules/fd-slicer/CHANGELOG.md
node_modules/fd-slicer/index.js
node_modules/nise/nise.js
node_modules/source-map-resolve/lib/source-map-resolve-node.js
node_modules/source-map-resolve/readme.md
node_modules/source-map-resolve/source-map-resolve.js
node_modules/yauzl/index.js
node_modules/yauzl/README.md
node_modules/rollup-plugin-node-globals/readme.md
node_modules/pify/readme.md
node_modules/extract-zip/index.js

These are the files that mention both setImmediate and use process-nextick-args. I think the problem is related to these, seeing that something outside of Sinon defines setImmediate using nextTick.

$ grep -l process-nextick-args  $(cat setImm_hits )
node_modules/mochify/node_modules/mocha/mocha.js
node_modules/readable-stream/lib/_stream_writable.js
node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js
node_modules/mocha/mocha.js
node_modules/mocaccino/node_modules/readable-stream/lib/_stream_writable.js
node_modules/mocaccino/node_modules/mocha/mocha.js
node_modules/puppeteer/.local-chromium/linux-674921/chrome-linux/resources/inspector/audits_worker/audits_worker_module.js
node_modules/stream-http/node_modules/readable-stream/lib/_stream_writable.js

I see a lot of stuff relating to Mochify and streams, @mantoni. Would you have any idea on what could be the root cause?

Before the upgrade there's only two dependencies in the hierarchy:

$ find node_modules/ -regex '.*/process-nextick-args/package.json'
node_modules/process-nextick-args/package.json
node_modules/mocaccino/node_modules/process-nextick-args/package.json

$ find node_modules/ -regex '.*/process-nextick-args/package.json' | xargs jq .version
"1.0.7"
"2.0.1"

After the upgrade, there are three (new is stream-http):

$ find node_modules/ -regex '.*/process-nextick-args/package.json'
node_modules/process-nextick-args/package.json
node_modules/mocaccino/node_modules/process-nextick-args/package.json
node_modules/stream-http/node_modules/process-nextick-args/package.json

carlerik at diffia9350 in /mnt/dev/sinon (2072-upgrade-browserify-bug)
$ find node_modules/ -regex '.*/process-nextick-args/package.json' | xargs jq .version
"1.0.7"
"2.0.1"
"2.0.1"

I've invested half an hour in diggin into this. While I can't explain why this happend, I came to the conclusion that Sinon does (and most probably always has been doing) the wrong thing regarding setImmediate.

Without upgrading anything, on the current master branch, create issue.js with this content:

'use strict';

console.log(String(window.setImmediate));

require('.').useFakeTimers();

console.log(String(window.setImmediate));

Running it with node_modules/.bin/mochify issue.js prints

# chromium:
undefined
function () {
                return clock[method].apply(clock, arguments);
            }

  0 passing (1ms)

As you can see, Chromium does not even implement setImmediate. I found an chromium bug report, where the maintainers stated that they're not willing to implement it: https://bugs.chromium.org/p/chromium/issues/detail?id=146172

I would say the issue isn't that setImmediate isn't properly restored, it shouldn't be installed in the first place. Currently, using Sinon fake timers in a browser environment makes setImmediate work while it actually shouldn't.

I have created a pull request with failing test cases demonstrating the issue. Unfortunately, I won't have time to continue to work on it today.

That's a pragmatic approach: just try and see if making Sinon not install the setImmediate makes the bug go away. I guess the actual fix might need to be done in Lolex.

I tested this out in lolex later on. Not reproducible there, so we just need to add a check in the Sinon install code for timers.

I found the sinner after seeing the suggested fix (sinonjs/lolex#268 and sinonjs/lolex#269) did _not_ fix the issue. It seems it's a browserify transform that does this: https://github.com/browserify/insert-module-globals/releases/tag/v7.1.0

I found out by just running mochify on a single test in test/util/fake-timers-test.js. If I commented out the line that created the clock, setImmediate would continue to be undefined. If I commented it in, it became defined.

Knowing that I avoid creating setImmediate in Lolex 5 (which is a dependency in #2131), I knew Lolex wasn't to blame either. So I googled some lines from the stringified definition of setImmediate and found the function definition in insert-module-globals, which is a a dependency of Browserify. By updating Browserify we went from v7.0.1 to 7.3.0 of this dependency, which started adding setImmediate in v7.2.

It seems as if this browserify transform installs this global if it detects setImmediate being used/referenced? In any cased, we are not be blamed here, it seems.

But there is one weird thing. I am wondering if Mochify does some funny business ...
I can see that the mentioned transform is being included in the mochify process: mochify --bundle bundle.js --consolify test/util/fake-timers-test.js, but it is _not_ included when building the Sinon bundle: npm run build.

@mantoni What could cause Mochify to to transformations that "normal" Browserify does not do?

Just to be clear:
the issue in this case is that something (Browserify) adds setImmediate to the global scope _after_ our detection code has already run, meaning that a lot of assumptions break. setImmediate starts out undefined and we expect it to be undefined at the end as well, but it has been set somewhere in the meantime.

Thank you for investigating this πŸ’―

I had to be part of the hackathon weekend, in some way, even if it was a bit async πŸ˜› Nice to finally get to the nitty-gritty of this.

I think I know the basic fix here (define opts.insertGlobalVars), but @mantoni needs to help me out a bit with the mochify bit.

I don't see any way of passing Browserify flags on the mochify command line. What I do see from the mochify docs is this:

The mochify function returns a Browserify instance. Please refer to the Browserify API for details.

I take it that means we need to replace our current CLI use of Mochify and replace it with a javascript (much like build.js)? I also assume it means that the returned browserify instance can be configured using additional opts? I might double post this for reference ...

@fatso83 Iβ€˜m happy to add more Browserify options to Mochify :)

Anyway, I think the issue lies within brout, a very old part of Mochify. It shims the process object for mocha and redirects write calls on stdout/stderr. This means that browserify detects the process object is being used and adds the global shim for it. It might be a good idea to run the internal browserify pipeline in Mochify with --no-insert-globals and provide a custom process shim in brout instead.

_Edit:_ The relevant line in brout is this: https://github.com/mantoni/brout.js/blob/14b62f4e8b88445f90a46adb1921c00921680087/lib/brout.js#L28

Eh, I'd love to provide a PR, but I wouldn't know what I would be doing, so ...

No worries. Iβ€˜ll fix it, and will try to come up with a solution that is easier to understand than the current one. But it will take a few days until I find the time.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NathanHazout picture NathanHazout  Β·  3Comments

kbirger picture kbirger  Β·  3Comments

zimtsui picture zimtsui  Β·  3Comments

stephanwlee picture stephanwlee  Β·  3Comments

fearphage picture fearphage  Β·  3Comments