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

SSR can't resolve builtin modules that start with underscore #5826

Closed
7 tasks done
cyco130 opened this issue Nov 24, 2021 · 7 comments · Fixed by #5827
Closed
7 tasks done

SSR can't resolve builtin modules that start with underscore #5826

cyco130 opened this issue Nov 24, 2021 · 7 comments · Fixed by #5827
Labels
feat: ssr p3-minor-bug An edge case that only affects very specific usage (priority)
Milestone

Comments

@cyco130
Copy link
Contributor

cyco130 commented Nov 24, 2021

Describe the bug

Some packages (like @prisma/client) require the builtin _http_common module (or others that start with an underscore) which causes ssrLoadModule to throw Error: Cannot find module '_http_common' imported from ... error. It seems to be caused by the builtin-modules package that Vite uses for this purpose filtering out modules that start with an underscore (changing the relevant regex in the transpiled code fixes the problem).

Reproduction

System Info

System:
    OS: Linux 5.4 Linux Mint 20.2 (Uma)
    CPU: (8) x64 Intel(R) Core(TM) i7-3630QM CPU @ 2.40GHz
    Memory: 1.70 GB / 15.53 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.18.1 - /usr/local/bin/node
    Yarn: 1.22.11 - ~/.npm-global/bin/yarn
    npm: 7.24.1 - ~/.npm-global/bin/npm
  Browsers:
    Chrome: 96.0.4664.45
    Firefox: 94.0

Used Package Manager

npm

Logs

No response

Validations

@Niputi Niputi added feat: ssr regression The issue only appears after a new release labels Nov 24, 2021
@patak-dev
Copy link
Member

See discussion in #5809 (comment) about this issue

@bluwy
Copy link
Member

bluwy commented Nov 24, 2021

Based on the discussion and the code, I think it had always been a bug in Vite and is not a regression. Unless this used to work in prior Vite versions?

@Niputi
Copy link
Contributor

Niputi commented Nov 24, 2021

its mentioned in #5709 that it used to work in 2.6.14

@ygj6
Copy link
Member

ygj6 commented Nov 25, 2021

its mentioned in #5709 that it used to work in 2.6.14

@Niputi No, I tested the above reproduction repo with vite@2.6.14 and got the same error. It is a bug of vite all the time, @bluwy is right.

In addition, I fetched your PR code and re-tested, it has solved the bug. 👍

@Niputi Niputi removed the regression The issue only appears after a new release label Nov 25, 2021
@Shinigami92 Shinigami92 added p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Nov 25, 2021
@bluwy
Copy link
Member

bluwy commented Nov 25, 2021

I took a look at why @prisma/client is using _http_common, looks like it's used by a dependency called https://github.com/nodejs/undici. From this comment, undici v4 should remove the need for _http_common, so all that's left is for @prisma/client to upgrade to v4, which is not done yet (prisma/prisma#7539). Maybe it's better to wait for the PR in the long term?

@patak-dev
Copy link
Member

I think we should add it, it is good that our isBuiltin is in sync with esbuild harcoded list

@cyco130
Copy link
Contributor Author

cyco130 commented Nov 25, 2021

Based on the discussion and the code, I think it had always been a bug in Vite and is not a regression. Unless this used to work in prior Vite versions?

I found about this trying to make @prisma/client work with 2.7 (it worked with 2.5 and 2.6). It does work when I fix this so I thought this was a regression. But the repro here doesn't work with 2.5 or 2.6 either (but Prisma does).

I'm not really sure what's going on, maybe some other bug was causing @prisma/client to work on 2.6 when it really shouldn't have because the _http_common import is there :) I don't think it's worth investigating since fixing this makes Prisma work.

@patak-dev patak-dev added this to the 2.7 milestone Nov 27, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Dec 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: ssr p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants