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

Extension fails to fetch dynamically imported module #544

Closed
4 tasks done
dlims opened this issue Nov 24, 2024 · 11 comments · Fixed by #552
Closed
4 tasks done

Extension fails to fetch dynamically imported module #544

dlims opened this issue Nov 24, 2024 · 11 comments · Fixed by #552

Comments

@dlims
Copy link

dlims commented Nov 24, 2024

Describe the bug

Tests launched from test explorer in browser mode fail to load extension module.

Reproduction

Just trying to run a test in browser mode from test explorer produces this error:

TypeError: Failed to fetch dynamically imported module: http://localhost:63315/@fs/C:/Users/dlore/.vscode/extensions/vitest.explorer-1.8.1/dist/setupFile.mjs?import&browserv=1732438481928

Output

[11:01:08 AM] Initiating deferred test run
[INFO 11:01:08 AM] Running 1 file(s): src/core/unit-test-browser/VitestBrowserExample.spec.browser.ts
[11:01:08 AM] The runner is starting because tests src/core/unit-test-browser/VitestBrowserExample.spec.browser.ts were started due to a file change
[INFO 11:01:08 AM] [Worker] The request url "C:/Users/dlore/.vscode/extensions/vitest.explorer-1.8.1/dist/setupFile.mjs" is outside of Vite serving allow list
[Error 11:01:08 AM] Error in C:/Users/dlore/Github/bauhaus_master/src/core/unit-test-browser/VitestBrowserExample.spec.browser.ts TypeError: Failed to fetch dynamically imported module: http://localhost:63315/@fs/C:/Users/dlore/.vscode/extensions/vitest.explorer-1.8.1/dist/setupFile.mjs?import&browserv=1732615268915
[11:01:08 AM] Marking "VitestBrowserExample.spec.browser.ts [browser]" as failed with 1 errors
[11:01:08 AM] Marking "VitestBrowserExample.spec.browser.ts [browser]" as failed with 1 errors
[11:01:08 AM] Ending test run src/core/unit-test-browser/VitestBrowserExample.spec.browser.ts
[11:01:09 AM] [VSCODE] Ignoring file: node_modules.vite\vitest\bcfb0f9579ecec702e2da1067b249218\results.json

Version

Vitest Explorer: 1.8.1
Vite: 5.4.10
Vitest: 2.1.5

Validations

@dlims
Copy link
Author

dlims commented Nov 24, 2024

The same test launched from script works properly

@hoisel
Copy link

hoisel commented Nov 25, 2024

+1

@PPDEMOone
Copy link

I have the same problem.

@sheremet-va
Copy link
Member

sheremet-va commented Nov 26, 2024

The "Output" field in this issue is not correct. It prints much more information, please don't crop it. Please read what the issue template says:

The content of "Output" tab. You can open this tab by typing "> Show Vitest Output Channel" in a search bar or pressing "See error" on an error message if there is one. Your issue will be closed if you do not provide the full output (starting with Vitest version) - do not remove any "irrelevant" information - the maintainer will decide if it is valuable or not.

Copy link

Hello @dlims. 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.

@sheremet-va
Copy link
Member

I will add "needs reproduction" label, but more output should be enough. I also need to know Vite and Vitest versions.

@dlims
Copy link
Author

dlims commented Nov 26, 2024

I will add "needs reproduction" label, but more output should be enough. I also need to know Vite and Vitest versions.

I've added requested info.

@kayahr
Copy link

kayahr commented Nov 27, 2024

Maybe this is some incompatibility to latest vitest or vitest/browser? I suddenly have the same problem in all my projects, so I tested it in a small demo project I created for a past issue:

https://github.com/kayahr/vitest-bugs-4

This demo project uses vitest 2.1.4 and I can't reproduce the problem there. But when I update vitest and vitest-browser dependency to 2.1.6 and restart vscode (or reload the tests) then I get the error:

image

Downgrading to 2.1.4 fixes the problem. With 2.1.5 it also doesn't work so I guess the problem was introduced in vitest 2.1.5. Or vitest/browser 2.1.5 (as only the browser tests are affected)

@bmthd
Copy link

bmthd commented Dec 3, 2024

I am facing the same problem with Vite 6.0.1,Vitest 2.1.5 and 2.1.6.
I am getting around this problem by fixing the version at 2.1.4.

P.S. I am using Vitest browser mode.

@jpzwarte
Copy link

jpzwarte commented Dec 7, 2024

New vitest user here, but i can also confirm it works with 2.1.4 and not 2.1.6.

@sheremet-va
Copy link
Member

Does this only happen with the browser mode?

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

Successfully merging a pull request may close this issue.

7 participants