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

Watcher crashes when reloading code that throws (regression mocha@7 to mocha@8) #4580

Closed
4 tasks done
marcelbeumer opened this issue Feb 20, 2021 · 5 comments · Fixed by #4614
Closed
4 tasks done
Labels
area: node.js command-line-or-Node.js-specific type: bug a defect, confirmed by a maintainer

Comments

@marcelbeumer
Copy link

marcelbeumer commented Feb 20, 2021

Prerequisites

  • Checked that your issue hasn't already been filed by cross-referencing issues with the faq label
  • Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
  • 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
  • Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with: node node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend that you not install Mocha globally.

Description

MCVE: please see https://github.com/marcelbeumer/mocha-8-watcher-issue for a minimal test case with STR.

Since mocha@8 the watcher crashes when reloading tests and a require fails, for example when causing a syntax error. Errors that happen during test execution are handled correctly by the watcher. Experimenting with different mocha versions, it turns out it is a regression from v7 to v8.

Steps to Reproduce

See MCVE: https://github.com/marcelbeumer/mocha-8-watcher-issue. It seems that when the watcher is reloading code that will throw when requiring, the watcher crashes.

Expected behavior:

The watcher does not crash when reloading test code. Behavior for the initial test run when starting the watcher is debatable but would be best if it handled both cases well.

Actual behavior:

The watcher crashes when reloading test code that causes an error.

Reproduces how often:

100%

Versions

  • The output of mocha --version and node node_modules/.bin/mocha --version: 8.30 (but also tried @8.0, and @7)
  • The output of node --version: v15.6.0
  • Your operating system
    • name and version: macOS 11.1
    • architecture (32 or 64-bit): 64
  • Your shell (e.g., bash, zsh, PowerShell, cmd): zsh
  • Your browser and version (if running browser tests):
  • Any third-party Mocha-related modules (and their versions):
  • Any code transpiler (e.g., TypeScript, CoffeeScript, Babel) being used (and its version): no, but same behavior with ts-node setup (see branch in https://github.com/marcelbeumer/mocha-8-watcher-issue)

Additional Information

@outsideris
Copy link
Contributor

When I tested your MCVE(nice MCVE), it only happened with node.js 15.x.
With 14.x and mocha v8 watcher is fine.

It seems it caused by node 15.x. But I'm not sure because mocha v7 is fine with node 15.x.

@outsideris outsideris added area: node.js command-line-or-Node.js-specific and removed unconfirmed-bug labels Mar 17, 2021
@marcelbeumer
Copy link
Author

Didn't Node 15 change handling of unhandled rejections to throw?
Maybe this in combination with mocha 8 refactorings for running things in parallel?

@outsideris
Copy link
Contributor

@marcelbeumer Yes, Node 15's default mode for unhandledRejection is changed to throw (from warn).
I am also strongly suspicious of this issue, but I have not yet confirmed it.

@outsideris outsideris added the type: bug a defect, confirmed by a maintainer label Mar 28, 2021
@juergba
Copy link
Contributor

juergba commented Apr 9, 2021

When I tested your MCVE(nice MCVE), it only happened with node.js 15.x.

I'm testing with Node v14.16.0 and the watcher crashes by the REQUIRE ERROR.

@outsideris
Copy link
Contributor

Could you test it with #4614 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: node.js command-line-or-Node.js-specific type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants