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

Debugger stops at at end of file when "stepping into" #5569

Open
4 tasks done
oliverschwendener opened this issue Apr 18, 2024 · 2 comments
Open
4 tasks done

Debugger stops at at end of file when "stepping into" #5569

oliverschwendener opened this issue Apr 18, 2024 · 2 comments
Labels

Comments

@oliverschwendener
Copy link

Describe the bug

I'm trying to debug tests in Visual Studio Code. I followed this guide: https://vitest.dev/guide/debugging.html to set up the vscode debugger and everything works fine, until I "step into" a function or method. The debugger does not stop on the correct line, but at the end of the file. I created a minimal repo to reproduce the issue: https://github.com/oliverschwendener/vitest-vscode-debugging-issue. Does anyone have an idea what could cause this issue? Did I misconfigure something?

Reproduction

https://github.com/oliverschwendener/vitest-vscode-debugging-issue

Output

[INFO 15:58:09] [v0.8.4] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 15:58:09] [API] Running Vitest: v1.5.0 (vite.config.mts)
[INFO 15:58:09] [API] Starting Vitest process with Node.js: /Users/oliverschwendener/.nvm/versions/node/v20.12.2/bin/node
[INFO 15:58:10] [API] Vitest process 94273 created
[INFO 15:58:11] [API] Collecting tests: src/Calculator.test.ts
[INFO 15:58:11] [API] Collecting tests: src/Calculator.test.ts
[INFO 15:58:33] [DEBUG] Starting debugging on localhost:53856
[INFO 15:58:33] Running 1 file(s) with name pattern: ^\s?add should add two numbers$
[Worker] Debugger listening on ws://127.0.0.1:53856/691b403d-7e0e-4ddc-8605-5c4ff72dd9f6
For help, see: https://nodejs.org/en/docs/inspector
[Worker] Debugger attached.
[INFO 15:58:33] [DEBUG] Debugging started

Version

v0.8.4

Validations

@hi-ogawa hi-ogawa added p3-minor-bug An edge case that only affects very specific usage (priority) upstream and removed pending triage p3-minor-bug An edge case that only affects very specific usage (priority) labels Apr 19, 2024
@hi-ogawa
Copy link
Contributor

hi-ogawa commented Apr 19, 2024

Thanks for the reproduction.

It looks like this is due to how Vite SSR transforms imports/exports internally. Vite replaces each named export with a getter of magic variable __vite_ssr..., so probably this getter call is making an weird jump. When I tested it, it goes to add body after "step into" 3 times, so that coincides with my assumption.

I'm not sure if there's a solution to this, but probably this issue is reproducible on plain Vite SSR, so actions need to be taken there.

Btw, you are using vscode debugger directly with own launch.json, so technically this is not vscode extension issue, which is what this repo is about (EDIT: now the issue is moved to main vitest repo). But, the same issue can reproduce either way.

@hi-ogawa hi-ogawa transferred this issue from vitest-dev/vscode Apr 19, 2024
@AriPerkkio
Copy link
Member

AriPerkkio commented Apr 19, 2024

This is very likely related to how Vite SSR transform modifies the variables: https://github.com/ariperkkio/vite-ssr-transform-sourcemaps-issue/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants