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]: Code execution does not break in debugging tool when watch mode is set #14336

Closed
cdoublev opened this issue Jul 17, 2023 · 3 comments
Closed

Comments

@cdoublev
Copy link

Version

29.6.1

Steps to reproduce

  1. Clone my repo at https://github.com/cdoublev/jest-issue
  2. node --inspect-brk=0.0.0.0:9222 ./node_modules/.bin/jest --watchAll (npm test)
  3. Open chrome://inspect/ in Chrome
  4. Click inspect in the target list

Expected behavior

I expect the code to break at the debugger line in ./add.js.

Actual behavior

The code did not break.

Additional context

I run the above steps in a virtual machine. I connect to the VM from my terminal with a SSH tunnel localhost:9222 -> 0.0.0.0:9222.

I have not checked if the problem occurs without the SSH tunnel because I am using a virtual machine so I do not have to install NodeJS on my machine's OS.

But I guess this problem is specific to this context, and is related to this change in version 29.6.0:

[jest-core] Always use workers in watch mode to avoid crashes (#14059)

Indeed, the code breaks when removing --watchAll from the command line arguments.

Environment

System:
  OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
  CPU: (1) x64 Intel(R) Core(TM) i7-3612QM CPU @ 2.10GHz
Binaries:
  Node: 20.3.0 - /usr/bin/node
  npm: 9.6.7 - /usr/bin/npm
npmPackages:
  jest: ^29.6.1 => 29.6.1
@mrazauskas
Copy link
Contributor

mrazauskas commented Jul 17, 2023

Seems like you are right about #14059. After it landed workers are used always instead of sometimes in watched mode. This means that your reproduction now fails always, but before it was failing sometimes. If I didn’t miss something. Might be that all worked as expected with --runInBand flag, but you are not mentioning it. (EDIT: Nope, see #6683)

All examples in debugging documentation use the --runInBand flag. The CRA example additionally sets --watchAll=false.

The configuration examples in vscode-jest repo also set --runInBand and --watchAll=false.

All this makes me think that it can be that the watch mode is not designed to work with debugger. For some reason. Can’t proof that.

@benjaminjkraft Could you take a look? I can’t recall if we did talk about respecting --runInBand in the watch mode? Does that make sense? (Sorry about the noise, I forgot about #14085.)

@cdoublev
Copy link
Author

cdoublev commented Jul 17, 2023

So the watch mode and debugging tools only worked together if --runInBand is set or if only one available core is detected? Curious to know why. There is nothing in the current version (v29.5.0) of the documentation about this.

The VM I am running Jest in has only one core (Virtual Box's default) therefore it always worked.

edit: there is a note explaining why --runInBand is somewhat mandatory for debugging, and #14085 seems to address my issue, therefore I am closing it.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants