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

Vite 4.0.1 and "You appear to have multiple instances of Solid" #1426

Closed
phungleson opened this issue Dec 15, 2022 · 17 comments
Closed

Vite 4.0.1 and "You appear to have multiple instances of Solid" #1426

phungleson opened this issue Dec 15, 2022 · 17 comments

Comments

@phungleson
Copy link
Contributor

Describe the bug

Hey peeps,

I am trying to upgrade my app to vite v4.0.1, however it ran into the error in header. The site cannot be loaded due to the error.

The error is clear and I understand what it means. However, I couldn't pin point which part of the app/libs caused the issue.

It would be great if someone has any thoughts how to debug this?

Thanks!

Your Example Website or App

N/A

Steps to Reproduce the Bug or Issue

Change to vite in package.json to 4.0.1 and run vite.

Expected behavior

The issue should not be there and everything loads correctly.

Screenshots or Videos

N/A

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: 108.0.5359.98 arm

Additional context

I am using latest of a few libs:

"solid-jest": "^0.2.0",
"solid-js": "^1.6.5",
"vite-plugin-solid": "^2.4.0"
"babel-preset-solid": "^1.6.2",
"solid-app-router": "^0.4.2",
@lxsmnsyc
Copy link
Member

Check the lockfile for possible duplicates

@atk
Copy link
Contributor

atk commented Dec 15, 2022

@lxsmnsyc we already found out that this is a bug introduced in the vite resolver in 4.0.1, we just haven't found the cause yet.

@itea-dev
Copy link

Today I updated my app to Vite 4 and it broke. It logs the same error as yours.

@phungleson
Copy link
Contributor Author

This seems to be the issue in vite #11385.

@kotx
Copy link

kotx commented Dec 17, 2022

For me, the culprit seems to be solid-router.

@ryansolid
Copy link
Member

I think it would hapoen to any package that has dependencies on solid-js. Make sure there is no duplication in your node modules and if there isn't it probably something new happening due to bundling in Vite 4.

@mdynnl
Copy link
Contributor

mdynnl commented Dec 17, 2022

I think vite@4.0.1 seems to be having trouble deduping optimized dependencies. If you look at the imports on dev with optimization enabled, for any package that depends on solid-js, solid-js is directly resolved from node_modules while it should be resolving from optimized one. Disabling optimizeDeps resolves this but this might not work with some packages especially cjs only packages.

virtuoushub added a commit to virtuoushub/solid-start-vite-4-and-pnpm-repro that referenced this issue Dec 17, 2022
@virtuoushub
Copy link

I think vite@4.0.1 seems to be having trouble deduping optimized dependencies. If you look at the imports on dev with optimization enabled, for any package that depends on solid-js, solid-js is directly resolved from node_modules while it should be resolving from optimized one. Disabling optimizeDeps resolves this but this might not work with some packages especially cjs only packages.

Can confirm adding:

...
  optimizeDeps: {
    disabled: "dev",
  },
...

fixed the issue I was seeing with vite@4.0.1 and the hacknews / solid-start example.

@ryansolid
Copy link
Member

ryansolid commented Dec 18, 2022

It was suggested to me that this commit might be responsible. We should try reversing it to confirm.

vitejs/vite#11290

@csr632
Copy link

csr632 commented Dec 18, 2022

Could anyone try this branch of vite vitejs/vite#11410 to test whether it is fixed?

@patak-dev
Copy link

In the meantime, we released vite@4.0.2 reverting vitejs/vite#11290.

@csr632
Copy link

csr632 commented Dec 18, 2022

In the meantime, we released vite@4.0.2 reverting vitejs/vite#11290.

I can confirm that this issue is fixed in vite@4.0.2. Tested with this template: npm init solid@latest.

@itea-dev
Copy link

In the meantime, we released vite@4.0.2 reverting vitejs/vite#11290.

Tested vite@4.0.2 on my app and this issue is fixed.

virtuoushub added a commit to virtuoushub/solid-start-vite-4-and-pnpm-repro that referenced this issue Dec 18, 2022
virtuoushub added a commit to virtuoushub/solid-start-vite-4-and-pnpm-repro that referenced this issue Dec 18, 2022
@orenelbaum
Copy link
Contributor

So I guess this issue can be closed?

@phungleson
Copy link
Contributor Author

Yep it works fine after vite@4.0.2 upgrade, thanks everyone!

@andrezero
Copy link

andrezero commented Feb 9, 2024

Hey there 👋

Running into this issue in a new setup (setting up a complex monorepo).

You appear to have multiple instances of Solid. This can lead to unexpected behavior.

This ☝️ shows up once per test test suite.

I have tried all combinations of config and the issue persists. I am afraid it might be more than just noise and more complex tests .

I have branched the repository for reproduction. sake.

Moving on with my sprint, might have more details once I start adding the actual production code.

Help appreciated 🙇

@andrezero
Copy link

Possibly related: #1720

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 a pull request may close this issue.