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

[Bug] 404s every page after enabling watch('content') to reloadRoutes() in static.config.js #985

Closed
theWebalyst opened this issue Jan 22, 2019 · 13 comments

Comments

Projects
None yet
5 participants
@theWebalyst
Copy link

commented Jan 22, 2019

Are you reporting a bug?

Yes

Note: this issue originally filed on my rs-basic-test repo: theWebalyst/rs-basic-test#1

Environment

react-static -V: 6.1.5
node -v: 8.11.3
npm -v: 6.4.1
Operating system: Ubuntu 18.10

Steps to Reproduce the problem

Starting with the basic template, I made small changes to get it to load content from markdown files by changing the relevant parts, based this other example: https://github.com/tannerlinsley/react-static-markdown (I chose to follow how that loads markdown having first failed to do this based on the code in the react-static archived markdown example).

You can reproduce the error by:

  • git clone https://github.com/theWebalyst/rs-basic-test/ && cd rs-basic-test && git checkout tags/take-content-from-markdown-files -b localtest && yarn && yarn start
  • visit http://localhost:3000/ and confirm Home, About, Blog etc load ok
  • remove the comment in static.config.js to enable reloadRoutes() at line 7
  • things work as expected if you just edit content
  • until you refresh the page or click on the navigation: Home, About, Blog etc all show a 404 error

I don't see any errors in browser or terminal console (using Firefox), but note that there is still some console.log() debug output generated to the terminal by the build (see static.config.js 15-17)

@gpoole

This comment has been minimized.

Copy link

commented Feb 1, 2019

I'm having the same issue, but I don't think it's caused by the call to reloadRoutes(). If I make any changes at all to my static.config.js and save I get 404s until I restart the watch server. I've also checked and the same thing happens in the linked example without the reloadRoutes() line being uncommented.

@theWebalyst

This comment has been minimized.

Copy link
Author

commented Feb 1, 2019

Phew, it isn't just me - always the expectation when learning something new 😄

I just updated the OP to reflect that if I start without the reloadRoutes() line, do yarn start, reload the site (all good so far). Then if I edit static.config.js to enable:

chokidar.watch('content').on('all', () => reloadRoutes())

...and save static.config.js, it works: changes to my content are hot reloaded as expected... until I refresh the page, or click on any navigation, or restart yarn start. Then it is all 404s again.

I'm not sure if this is consistent with your report @gpoole?

@gpoole

This comment has been minimized.

Copy link

commented Feb 4, 2019

Yep, sounds like we're having the same problem @theWebalyst. I can reproduce what you described just by starting the server and touching the file without making any changes, so I think it must be something to do with the configuration being reloaded.

@gpoole

This comment has been minimized.

Copy link

commented Feb 4, 2019

Oh I should also add that I've found that calling reloadRoutes itself is ok, it works as expected. I have a similar setup where I'm watching a directory for changes to yaml files, and that works fine as long as I don't touch static.config.js after starting the dev server.

@theWebalyst

This comment has been minimized.

Copy link
Author

commented Feb 4, 2019

@gpoole if I h understand you, you only get a problem if you edit static.config.js after starting yarn start, so I'm not sure it's the same problem.

I don't have to do that, I just used that procedure in the OP to demonstrate that the issue is dependent on the chokidar line. If that line is enabled, all I have to do is click on the navigation links (Home, About, Blog) and I'll get 404s. I don't have to modify any of the source or content. (Going from memory there but pretty sure!).

@theWebalyst

This comment has been minimized.

Copy link
Author

commented Feb 12, 2019

@tannerlinsley did you have a look at this?

@theWebalyst theWebalyst changed the title 404s every page after enabling watch('content') to reloadRoutes() in static.config.js [Bug] 404s every page after enabling watch('content') to reloadRoutes() in static.config.js Feb 27, 2019

@oscartbeaumont

This comment has been minimized.

Copy link

commented Mar 2, 2019

I am also having this issue. If I startup react-static and then just save the static.config.js without even making a change to the file, all of my routes return 404.

@oscartbeaumont

This comment has been minimized.

Copy link

commented Mar 7, 2019

@tannerlinsley can you have a look at this?

@tannerlinsley

This comment has been minimized.

Copy link
Collaborator

commented Mar 7, 2019

@Blobson

This comment has been minimized.

Copy link
Contributor

commented Mar 30, 2019

Hi! Just wondering if there any progress on the issue? I'd really love to migrate to react-static from gatsby but for now it is a major showstopper for me.

@tannerlinsley

This comment has been minimized.

Copy link
Collaborator

commented Mar 30, 2019

@Blobson

This comment has been minimized.

Copy link
Contributor

commented Mar 30, 2019

This is great! Can't wait to try it out.

@tannerlinsley

This comment has been minimized.

Copy link
Collaborator

commented Apr 1, 2019

v7 is now available to try at react-static@next or react-static@7.

Be sure to use the new reloadClientData instead of the deprecated reloadRoutes method. Thanks!

sw-yx added a commit that referenced this issue Apr 21, 2019

Update documentation "reloadRoutes" -> "reloadClientData" (#1145)
* update name "reloadRoutes" to "reloadClientData"

per #985 (comment)

* Update config.md

* Update config.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.