vitest-dev / vscode

VS Code extension for Vitest
https://vitest.dev/vscode
MIT License
740 stars 83 forks source link

[Windows] Hangs at "Resolving Vitest..." forever #312

Closed Nithanim-Work closed 5 months ago

Nithanim-Work commented 5 months ago

Describe the bug

Using this extension v0.5.6 just shows "Resolving Vitest..." in the "Testing" tab of VS Code forever. We are using yarn with the pnp structure.

I tried debugging it (using latest master dad5884, sorry) and finally traced it back to https://github.com/vitest-dev/vscode/blob/main/src/api.ts#L276

I am not sure how this works but somehow the case is not handled where node does something (and exits?) but not starting any messaging. Capturing the stderr reveals the following:

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
    at new NodeError (node:internal/errors:405:5)
    at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:131:11)
    at defaultLoad (node:internal/modules/esm/load:82:3)
    at nextLoad (node:internal/modules/esm/loader:163:28)
    at ESMLoader.load (node:internal/modules/esm/loader:603:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
    at new ModuleJob (node:internal/modules/esm/module_job:64:26)
    at #createModuleJob (node:internal/modules/esm/loader:480:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'

The "options" to the fork function was:

{
  "execPath":"",
  "execArgv": [
    "--require",
    "c:\\Users\\redacted\\repo\\.pnp.cjs",
    "--experimental-loader",
    "c:\\Users\\redacted\\repo\\.pnp.loader.mjs"
  ],
  "env": {
    "ELECTRON_RUN_AS_NODE":"1",
    "ELECTRON_USE_V8_CONFIGURED_PARTITION_POOL":true
  },
  "stdio":"overlapped",
  "cwd": "C:/Users/redacted/repo"
}

Back where this comes from should be https://github.com/vitest-dev/vscode/blob/dad58842672344c686a63eedd80b48aa662dc1ec/src/api/resolve.ts#L55-L57 There, pnpPath is c:\Users\redacted\repo\.pnp.cjs and folder.uri.fsPath is c:\Users\redacted\repo.

Honestly, I am not sure, how this works on non-Windows platforms. I would assume that the path is also absolute but then again it complains that it is not file://?

Thank you in advance!

(Unrelated note: The "Contributing" link for the issue template is broken.)

Reproduction

Any yarn pnp project on windows, I assume.

System Info

System:
    OS: Windows 11 10.0.22621
    CPU: (20) x64 13th Gen Intel(R) Core(TM) i7-1370P
    Memory: 32.30 GB / 63.66 GB
  Binaries:
    Node: 20.11.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 4.1.1 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.12.1 - C:\Program Files\nodejs\pnpm.CMD
  IDEs:
    VSCode: 1.87.2 - C:\Program Files\Microsoft VS Code\bin\code.CMD
  Browsers:
    Edge: Chromium (122.0.2365.92)
    Internet Explorer: 11.0.22621.1

Used Package Manager

yarn

Validations

sheremet-va commented 5 months ago

Yarn PnP is not supported yet.

sheremet-va commented 5 months ago

Also, please provide a minimal Yarn PnP project.

github-actions[bot] commented 5 months ago

Hello @Nithanim-Work. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.