Skip to content

fix(vm): fix external module resolve error with deps optimizer query#10024

Merged
sheremet-va merged 7 commits intovitest-dev:mainfrom
hi-ogawa:fix/vmthreads-optimized-deps-query-params
Mar 30, 2026
Merged

fix(vm): fix external module resolve error with deps optimizer query#10024
sheremet-va merged 7 commits intovitest-dev:mainfrom
hi-ogawa:fix/vmthreads-optimized-deps-query-params

Conversation

@hi-ogawa
Copy link
Copy Markdown
Collaborator

@hi-ogawa hi-ogawa commented Mar 30, 2026

Description

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

hi-ogawa and others added 2 commits March 30, 2026 15:41
…alModulesExecutor

Vite appends `?v=<browserHash>` to optimized-dep URLs for cache busting.
When vmThreads externalizes such a dep, the path including `?v=...` was passed
directly to `fs.existsSync`, which has no concept of URL query params, causing
a "Cannot find module" error.

Fix by splitting the identifier into path and query upfront via `cleanUrl`,
then reconstructing the file URL with the query preserved for module cache
identity while using the clean path for filesystem operations.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 30, 2026

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit e9134a5
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/69ca1b9781bdb0000942ee2f
😎 Deploy Preview https://deploy-preview-10024--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

hi-ogawa and others added 5 commits March 30, 2026 15:46
…alModulesExecutor

Vite appends `?v=<browserHash>` to optimized-dep URLs for cache busting.
When vmThreads externalizes such a dep, the path including `?v=...` was passed
directly to `fs.existsSync`, which has no concept of URL query params, causing
a "Cannot find module" error.

Fix by splitting the identifier into path and query upfront via `splitFileAndPostfix`,
then reconstructing the file URL with the query preserved for module cache
identity while using the clean path for filesystem operations.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
}

const extension = extname(identifier)
const { file, postfix } = splitFileAndPostfix(identifier)
Copy link
Copy Markdown
Collaborator Author

@hi-ogawa hi-ogawa Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added splitFileAndPostfix here, so later pathUrl won't include ?v=..., which was the cause of existsSync not finding the file and causing module not found.

@hi-ogawa hi-ogawa marked this pull request as ready for review March 30, 2026 07:36
@sheremet-va sheremet-va merged commit 9dbf477 into vitest-dev:main Mar 30, 2026
15 of 16 checks passed
@hi-ogawa hi-ogawa deleted the fix/vmthreads-optimized-deps-query-params branch March 30, 2026 08:41
@marcebdev
Copy link
Copy Markdown

Any ideas when this may release as a patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vmThreads/vmForks pool crashes with ERR_MODULE_NOT_FOUND when deps.optimizer.client.enabled is true

3 participants