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

moduleGraph.safeModulesPath entries truncated unconditionally #6516

Closed
7 tasks done
dominikg opened this issue Jan 15, 2022 · 1 comment · Fixed by #6518
Closed
7 tasks done

moduleGraph.safeModulesPath entries truncated unconditionally #6516

dominikg opened this issue Jan 15, 2022 · 1 comment · Fixed by #6518

Comments

@dominikg
Copy link
Contributor

Describe the bug

First 4 characters are missing. eg "e_modules/.vite/chunk-TFQY2HEV.js" instead of "/node_modules/.vite/chunk-TFQY2HEV.js"

found via sveltekit sveltejs/kit#3349

@bluwy traced it to

// record as safe modules
server?.moduleGraph.safeModulesPath.add(
cleanUrl(url).slice(4 /* '/@fs'.length */)
)

Reproduction

https://github.com/Rich-Harris/vite-safe-modules-repro

System Info

vite 2.7.12 via sveltekit 1.0.0-next.230


  System:
    OS: Linux 5.12 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (12) x64 AMD Ryzen 5 4600H with Radeon Graphics
    Memory: 2.79 GB / 15.07 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.0/bin/yarn
    npm: 8.3.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
  Browsers:
    Chrome: 97.0.4692.71
    Firefox: 96.0

Used Package Manager

pnpm

Logs

No response

Validations

@dominikg
Copy link
Contributor Author

dominikg commented Jan 15, 2022

Looking into it i found
https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/middlewares/static.ts#L151-L157

and it looks like ensureLeadingSlash and normalizePath should be called before adding. stripping /@fs/ should also be done on the condition that it exists.

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