-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
--inspect-brk
runs immediately when the debugger attaches
#6103
Comments
I'm unable to reproduce this. Debugger stops immediately on top of the |
Hello @leduyquang753. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with |
It might be dependent on the environment as that's macOS and I'm on Windows. Then what kind of "reproduction" do I have to do? Screen recording? |
The test case seems to be skipped on Windows too. Maybe there is indeed something broken. vitest/test/cli/test/inspect.test.ts Line 10 in bd83f6c
As most of us don't have access to Windows machines it would be amazing to get pull request with the fix for this. The related code is around here: vitest/packages/vitest/src/runtime/inspector.ts Lines 9 to 13 in bd83f6c
|
Found the issue. It's that on Windows, file paths begin with the drive letter The bigger issue now is that when Vitest is run by |
Awesome, thanks for looking into this! Could you try if this minimal repro works on Windows? If not, what changes are required for it to work? #5355 (comment)
We run all tests on CI on Windows too. The ones that are marked as
Do you have any suggestions how this could be improved? Always happy to extend support for all platforms. At least I thought our Windows support is very good. 🙌
I'm not sure I'm following here, but to me it sounds like you are seeing NodeJS issues with |
It does work and break properly.
I had not done anything with the codebase at the time. I cloned the repository, set it up and ran the test suite right away. (
So the |
I'm also seeing these failures locally. Looks like all tests require
If I change the relative filepath to full absolute one, it doesn't work on Windows anymore. 🤔 Both of the versions below work on all platforms except Windows. After the change it works on Windows too, weird. const filename = resolve("./target.mjs");
-const url = new URL(filename, import.meta.url).href; // Does not work on Windows
+const url = pathToFileURL(filename); // Works on all platforms
session.post("Debugger.setBreakpointByUrl", { url, lineNumber: 0 }); There's fix for the original issue on #6110. It also enables the test case on Windows CI which seems to pass fine now. Thanks for the root cause analysis! If there's anything else that doesn't work on your final project on Windows, feel free to file bug reports for those. I'm still surprised to hear that this small bug on |
Describe the bug
When a debugger like Chrome DevTools attaches to
vitest --inspect-brk
, the code is immediately and prematurely resumed execution.It appears that the execution is resumed when
Runtime.runIfWaitingForDebugger
is called by the debugger. The execution is still paused when using the normalnode --inspect-brk
.Reproduction
Very simple source files:
test.ts
:test.spec.ts
:Run
vitest --run --inspect-brk --no-file-parallelism
and attach a debugger such as Chrome DevTools.System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: