Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] - ReferenceError: process is not defined #221

Closed
saschb2b opened this issue Jan 12, 2024 · 7 comments · Fixed by #222
Closed

[Bug] - ReferenceError: process is not defined #221

saschb2b opened this issue Jan 12, 2024 · 7 comments · Fixed by #222

Comments

@saschb2b
Copy link

saschb2b commented Jan 12, 2024

Our project bumps package versions automatically and since 5.1.7 our tests fail with

Chrome Headless 93.0.4577.82 (Linux x86_64) ERROR
  An error was thrown in afterAll
  Uncaught ReferenceError: process is not defined
  ReferenceError: process is not defined
      at Object.call (http://localhost:8080/_karma_webpack_/webpack:/node_modules/nise/nise.js:9816:1)
      at o (http://localhost:8080/_karma_webpack_/webpack:/node_modules/nise/nise.js:1:629)
      at require (http://localhost:8080/_karma_webpack_/webpack:/node_modules/nise/nise.js:1:680)
      at Object.call (http://localhost:8080/_karma_webpack_/webpack:/node_modules/nise/nise.js:686:15)
      at o (http://localhost:8080/_karma_webpack_/webpack:/node_modules/nise/nise.js:1:629)
      at require (http://localhost:8080/_karma_webpack_/webpack:/node_modules/nise/nise.js:1:680)
      at Object.call (http://localhost:8080/_karma_webpack_/webpack:/node_modules/nise/nise.js:336:11)
      at o (http://localhost:8080/_karma_webpack_/webpack:/node_modules/nise/nise.js:1:629)
      at require (http://localhost:8080/_karma_webpack_/webpack:/node_modules/nise/nise.js:1:680)
      at Object.12../fake-server (http://localhost:8080/_karma_webpack_/webpack:/node_modules/nise/nise.js:1646:17)

After reverting back to version 5.1.5 it works as intended.

Not really sure what could be the culprit here. Only saw the major version bump in sinon common package as dependencies? Was there a breaking change that I'm not aware of?

@fatso83
Copy link
Contributor

fatso83 commented Jan 15, 2024

Hmm ... I have no idea what this could be. The only change between sinon-commons 2 and 3 is that we stopped testing old Node versions. No code changes. See sinonjs/commons@b0253f8

The most probably culprit is the Browserify thingie, but that should not be used by you, AFAIK, as you don't use the bundled version.

If you are able to reproduce some minimal example, that would be great.

@saschb2b
Copy link
Author

Thanks for the details. We are still using Node 14. With the mentioned dropped support I guess that's the culprit.

If it is anything else, I'll add it here for further reference. For now this can be savely close. Thanks again

@mantoni
Copy link
Member

mantoni commented Jan 16, 2024

I see a lot of webpack in the stacktrace. It could well be the browserify thingy.

@pichlermarc
Copy link

pichlermarc commented Jan 29, 2024

Hmm, we're having a similar issue when running tests with sinon@15.12.2 within karma-webpack. Dependencies for sinon are set up in a way that it'll pull in nise@5.1.7. The same issue seems to exist with nise@5.1.6.

I've looked through the bundled code and nise.js:9816 seems to be the place where it tries to evaluate if (process.env.NODE_DEBUG) { which then fails as process is not defined in the browser. It's rather easy to reproduce as well, by

  • creating a file index.html
  • adding <script src="https://unpkg.com/nise@5.1.7/nise.js"></script> (using unpkg instead of installing and running karma-webpack for simplicity)
  • opening the file (index.html) in the latest version of Firefox
  • checking the log output in the dev tools
  • see the following error:
Uncaught ReferenceError: process is not defined
    [60]< https://unpkg.com/nise@5.1.7/nise.js:9816
    o https://unpkg.com/nise@5.1.7/nise.js:1
    o https://unpkg.com/nise@5.1.7/nise.js:1
    [9]< https://unpkg.com/nise@5.1.7/nise.js:686
    o https://unpkg.com/nise@5.1.7/nise.js:1
    o https://unpkg.com/nise@5.1.7/nise.js:1
    [8]< https://unpkg.com/nise@5.1.7/nise.js:336
    o https://unpkg.com/nise@5.1.7/nise.js:1
    o https://unpkg.com/nise@5.1.7/nise.js:1
    [12]< https://unpkg.com/nise@5.1.7/nise.js:1646
    o https://unpkg.com/nise@5.1.7/nise.js:1
    r https://unpkg.com/nise@5.1.7/nise.js:1
    <anonymous> https://unpkg.com/nise@5.1.7/nise.js:1
    <anonymous> https://unpkg.com/nise@5.1.7/nise.js:1
    <anonymous> https://unpkg.com/nise@5.1.7/nise.js:1

That being said I'm not sure if this was ever supported, our workaround at the moment is to pin nise@5.1.5

@fatso83 fatso83 reopened this Jan 29, 2024
@fatso83
Copy link
Contributor

fatso83 commented Jan 29, 2024

Thanks for adding details! I know @saschb2b closed it after I mentioned dropping explicit Node 14 support, but that was extremely unlikely to be the issue. Pretty sure we can figure this out quite quickly by running a git bisect script on the commit range, but I am swamped at the moment.

If anyone fancies a try:
https://github.com/fatso83/git-bisect-scripts/tree/master/examples

@pichlermarc
Copy link

pichlermarc commented Jan 30, 2024

Hi, thanks for the reply @fatso83 🙂

I cloned this repo and tried a few things out, and I think this may be a browserify bug (?) that affects the bundle in this package.

From main, if I change the dependency in package.json back to browserify@^16.2.3 from currently browserify@^17.0.0 then npm install && npm run bundle then the resulting bundle does not include this if (process.env.NODE_DEBUG) { line which causes trouble in nise@>=5.1.6 versions. So the commit that introduced this is most likely 6a5d5d4

@fatso83
Copy link
Contributor

fatso83 commented Jan 30, 2024

That's exactly what I and Max thought as well. The change log does not list this as a breaking change:
https://github.com/browserify/browserify/blob/HEAD/changelog.markdown

But I absolutely think this is it. Will revert and test

fatso83 added a commit that referenced this issue Jan 31, 2024
fatso83 added a commit that referenced this issue Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants