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

Skipping build. Vite assets are already up-to-date (causes vite not to connect) #20

Closed
cj opened this issue Mar 1, 2021 · 10 comments
Closed

Comments

@cj
Copy link

cj commented Mar 1, 2021

bin/rake vite:info
Running via Spring preloader in process 70795
Is bin/vite present?: true
vite_ruby: 1.0.4
vite_rails: 2.0.2
rails: 6.1.3
node: v14.5.0
npm: 6.14.11
yarn: 1.22.4
ruby: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]

vite-plugin-ruby:
app-template@0.0.0-semantic-release /Users/cj/Documents/apps/SnapNHD/snap
└── vite-plugin-ruby@1.0.13

When I receive the following:

RuntimeError - conflicting chdir during another chdir block:
  app/views/layouts/application.html.erb:13
  app/controllers/auth_controller.rb:10:in `block (2 levels) in <class:AuthController>'

Skipping build. Vite assets are already up-to-date ⚡️
Skipping build. Vite assets are already up-to-date ⚡️

It does not output the following in the console and vite's auto-refresh does not work:

[vite] connecting...
2DevTools failed to load SourceMap: Could not load content for http://localhost:3000/vite-dev/@fs/Users/cj/Documents/apps/SnapNHD/snap/node_modules/.vite/chunk.IXVMP6XR.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

p.s. I am also getting a 404 error randomly.

Let me know if I can provide any more information.

Cheers!

@cj cj added the bug: pending triage Something doesn't seem to be working, but hasn't been verified label Mar 1, 2021
@cj
Copy link
Author

cj commented Mar 1, 2021

I have also seen this error:

The server is configured with a public base URL of /vite-dev/ - did you mean to visit /vite-dev/application.js instead?

When visiting the URL from:

The resource at “http://localhost:3000/vite-dev/application.js” preloaded with link preload was not used within a few seconds. Make sure all attributes of the preload tag are set correctly.

@cj
Copy link
Author

cj commented Mar 1, 2021

I am also randomly seeing this in the rails logs:

ActionController::RoutingError (No route matches [GET] "/vite-dev/@fs/Users/cj/Documents/apps/SnapNHD/snap/node_modules/.vite/debounced.js"):


ActionController::RoutingError (No route matches [GET] "/vite-dev/@fs/Users/cj/Documents/apps/SnapNHD/snap/app/assets/channels/index.js"):

@ElMassimo
Copy link
Owner

ElMassimo commented Mar 1, 2021

Please share the structure of your sourceCodeDir, and the contents of config/vite.json and vite.config.js, and the version of vite.

Try starting the dev server by running bin/vite dev or npx vite, which should output more detailed problems.

If that does not work, try deleting built assets and compile manually: bin/rake vite:clobber and bin/vite build, and make sure it compiles successfully.

There's an example Rails app on this repo that you can check to verify your setup (entrypoints, source code location, etc).

@ElMassimo ElMassimo added bug: needs reproduction and removed bug: pending triage Something doesn't seem to be working, but hasn't been verified labels Mar 1, 2021
@cj
Copy link
Author

cj commented Mar 1, 2021

@ElMassimo here are the contents of those files https://gist.github.com/cj/e9f978c5d1c59ba0757b1ba0a5483f0d (I have also tried removing the babel plugin).

CleanShot 2021-03-01 at 09 10 13

bin/vite dev is what I use to run the server when developing.

This is what I used as an example to make sure mine was setup correctly https://github.com/ElMassimo/vite_ruby/tree/main/examples/rails

I will try and get you a standalone repo today/tomorrow, thank you again for taking a look!

@cj
Copy link
Author

cj commented Mar 1, 2021

@ElMassimo here is also a full output of the rails console logs when starting up https://gist.github.com/cj/506fe28316a4216767fd56f1537de18f

@ElMassimo
Copy link
Owner

A standalone repo would be great, thanks.

I won't have computer access until Wednesday, I'll take a look then.

Looking at the traces you added, something that seems odd is that these requests are not being forwarded to Vite by the dev server proxy, can you check that it's being included in the Rack middleware? Also, which Vite version are you using?

Sidenote: The components folder should live inside your source code dir (app/assets), or make sure to add it to watchAdditionalPaths so that changes are detected by Vite Ruby for recompilation when the dev server has not started.

@cj
Copy link
Author

cj commented Mar 2, 2021

@ElMassimo so looks like I figured out a temporary fix by increasing "devServerConnectTimeout": 30 from the default 0.1. It seems to randomly take 15+ seconds to compile sometimes, especially when loading async javascript imports. I am going to have to do some more digging to figure out why.

@ElMassimo
Copy link
Owner

ElMassimo commented Mar 2, 2021

The timeout should not be related with the compilation time, it's the timeout to check whether the dev server is running.

What hardware are you using, are you running in a VM or other resource-constrained environment?

@cj Make sure to add the components folder to your config/vite.json, otherwise changes to the components won't trigger a recompilation because they are outside your sourceCodeDir:

{
  "all": {
    "watchAdditionalPaths": ["app/components/**/*"]
  },

@ElMassimo
Copy link
Owner

Added a troubleshooting section describing possible causes.

Closing this for now, we can reopen it if none of the steps help, and you provide a reproduction 😃

@boriscy
Copy link

boriscy commented Oct 31, 2022

bin/rake vite:clobber and bin/vite build

Running these fixed my problems

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

No branches or pull requests

3 participants