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

Basic installation leads to unexpected (non-working) results — missing bundle #1483

Closed
jasonfb opened this issue Sep 23, 2022 · 3 comments
Closed

Comments

@jasonfb
Copy link

jasonfb commented Sep 23, 2022

Environment

  1. Ruby version: 3.1.2
  2. Rails version: 7.0.4
  3. Webpacker version: 6.5.2
  4. React on Rails version: 13.0.2

Expected behavior

The HelloWorld component is rendered to the screen when I navigate to http://localhost:3000/hello_world

Actual behavior

No component is rendered and the hello-world-bundle.js cannot be found

ReactOnRailsWithWebpacker 2022-09-23 08-46-14

also, there is an error message about how these resources cannot be loaded:

GET http://localhost:3000/packs/js/vendors-node_modules_prop-types_index_js-node_modules_react-on-rails_node_package_lib_ReactOn-ee470b.js net::ERR_ABORTED 404 (Not Found)
hello_world:9 GET http://localhost:3000/packs/js/hello-world-bundle.js net::ERR_ABORTED 404 (Not Found)

Small, reproducible repo

https://github.com/jasonfb/ShakapackerH

steps to reproduce:

rails new MyGreatApp --skip-javascript
rails generate controller Welcome (note: I know this is outside of the normal setup)
• add gems
bundle exec rails webpacker:install
rails generate react_on_rails:install
• start the app with foreman start -f Procfile.dev-static (in my app I have put this into a shell script at ./bin/dev)

go to http://localhost:3000/hello_world

@jasonfb
Copy link
Author

jasonfb commented Sep 23, 2022

this is very strange, upon a 2nd retry, the app started working as expected.

I reproduced another app and it worked. then I went back to this app and it also started working.

I wish I knew what I did to create the borked version.
ReactOnRailsWithWebpacker 2022-09-23 10-33-29

@jasonfb
Copy link
Author

jasonfb commented Sep 23, 2022

my suspicion is that there a certain conditions where for whatever reason the pack isn't rebuilt (even though I am examining the output of the webpack dev server and I didn't see those). Somehow, in this state, the frontend is loading the old (wrong) pack. I've seen this too in other cases as well which can lead to a confusing development state. will open a discussion regarding this.

@jasonfb
Copy link
Author

jasonfb commented Sep 23, 2022

Ok so I pulled this repository (https://github.com/jasonfb/ShakapackerH) booted it up into a different folder, and et viola, the problem does not remanifest.

I think there must be something super picky about when the browser hangs onto old (unrebuilt) packs? that's the only explanation I can come up with for this so I am closing and will move into an issue.

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

No branches or pull requests

1 participant