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

The test doesn't run when I set breakpoints in my TypeScript Node.js code using VSCode and Linux Mint #1798

Closed
kody-liu opened this issue Sep 12, 2023 · 5 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster *out-of-scope Posted issue is not in scope of VS Code

Comments

@kody-liu
Copy link

Describe the bug
The test doesn't run when I set breakpoints in my TypeScript Node.js code using VSCode.
My OS: Linux Mint

But after using my workplace MacBook, the breakpoints work as expected, but they still don't work on my Linux Mint desktop

To Reproduce
Steps to reproduce the behavior:

  1. Using Linux Mint as the operating system.
  2. Clone my repo: https://github.com/kody-liou/vitest_breakpoint_not_working
  3. Set a breakpoint in tests/my.test.ts using Visual Studio Code (VSCode).
  4. In the javascript debug terminal, execute the command: yarn test.
  5. Observe that the test is not running

Log File

/home/kody/.nvm/versions/node/v18.17.1/bin/node ./node_modules/vitest/vitest.mjs /media/kody/本機磁碟_4/_src/personal/vitest_breakpoint_not_working/tests/my.test.ts -t my test can set breakpoint --api.port 42349 --api.host 127.0.0.1
 DEV  v0.34.4 /media/kody/本機磁碟_4/_src/personal/vitest_breakpoint_not_working
      API started at http://127.0.0.1:42349

VS Code Version: version 1.82

@kody-liu kody-liu added the bug Issue identified by VS Code Team member as probable bug label Sep 12, 2023
@connor4312
Copy link
Member

THanks for the issue, unfortunately I don't hit this on my Linux machine. Can you please do the following:

  1. Add this to your workspace settings (the Preferences: Open Workspace Settings (JSON) command): "debug.javascript.terminalOptions": { "trace": {"logFile": "${workspaceFolder}/log.txt"}}
  2. Reproduce the issue with the debug terminal
  3. Share the contents of the "log.txt" file created in your workspace

@connor4312 connor4312 added the info-needed Issue requires more information from poster label Oct 4, 2023
@kody-liu
Copy link
Author

kody-liu commented Oct 9, 2023

I've generated the 'log.txt' file using the steps you provided, but the content is too long to paste in a comment. Therefore, I've committed it to my repository. You can find the 'log.txt' file here: https://github.com/kody-liou/vitest_breakpoint_not_working/blob/main/log.txt

@connor4312
Copy link
Member

It looks like the debugger never gets attached to the process that's actually running tests.

I wonder if something in your environment is overriding the NODE_OPTIONS environment variable: this is required in order for the debugger to find the process. In your test file, if you console.log(process.env.NODE_OPTIONS), you should see something like --require <some-path>/bootloader.js. If not, that's what's happening.

@kody-liu
Copy link
Author

I switched to using Ubuntu, but the problem remained the same. I set some breakpoints and tried to use fs.writeFileSync to display the process.env.NODE_OPTIONS. However, in the JavaScript Debug Terminal, the file was not created. After I removed all the breakpoints and used the JavaScript Debug Terminal to run yarn test again, it successfully generated the file with the following content:

" --require /snap/code/142/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/bootloader.js --inspect-publish-uid=http"

@connor4312
Copy link
Member

Thanks, on a closer look, this is a Node.js bug: nodejs/node#50516

You can work around it by locating your workspace in a path without mutli-byte characters in its path.

@connor4312 connor4312 added the *out-of-scope Posted issue is not in scope of VS Code label Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster *out-of-scope Posted issue is not in scope of VS Code
Projects
None yet
Development

No branches or pull requests

2 participants