-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Hugo not recover from error after failed to parse invalid .Data #7043
Comments
Same error here as I missed a ":"
|
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
unstale bot 🤖 |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
unstale bot 🤖 |
What you don't write @pamubay is, how you run your server. It might be that you run it with parameters that do not rebuild everthing on changes? If not, then this might be a data-directory watching issue. |
its basic i even try Hugo rebuild triggered after i changed the file under except, we edit the config file, then Hugo will rebuild and works correctly. hugo version:
|
Running |
Yes |
Just had the same issue on |
Really interesting bug. |
Having this issue on |
When *Init.Do executes the *Init's f function, it stores the error in the *Init's err field and returns ini.err. If we call an *Init's Do method again, and there is no error in the subsequent call, ini.err remains unchanged, and *Init.Do returns it again. This becomes an issue for the "hugo server" command, which calls h.init.data.Do within *HugoSites.Data every time the site is rebuilt. If "hugo server" is started with a valid data file, and that data file is edited to make it invalid (e.g., with poorly formatted JSON), then any attempt to fix the data file only causes Hugo to return the same error. The fix is to ensure that *Init.Do resets ini.err to nil with each call. Fixes gohugoio#7043
When *Init.Do executes the *Init's f function, it stores the error in the *Init's err field and returns ini.err. If we call an *Init's Do method again, and there is no error in the subsequent call, ini.err remains unchanged, and *Init.Do returns it again. This becomes an issue for the "hugo server" command, which calls h.init.data.Do within *HugoSites.Data every time the site is rebuilt. If "hugo server" is started with a valid data file, and that data file is edited to make it invalid (e.g., with poorly formatted JSON), then any attempt to fix the data file only causes Hugo to return the same error. The fix is to ensure that *Init.Do resets ini.err to nil with each call. Fixes gohugoio#7043
When *Init.Do executes the *Init's f function, it stores the error in the *Init's err field and returns ini.err. If we call an *Init's Do method again, and there is no error in the subsequent call, ini.err remains unchanged, and *Init.Do returns it again. This becomes an issue for the "hugo server" command, which calls h.init.data.Do within *HugoSites.Data every time the site is rebuilt. If "hugo server" is started with a valid data file, and that data file is edited to make it invalid (e.g., with poorly formatted JSON), then any attempt to fix the data file only causes Hugo to return the same error. The fix is to ensure that *Init.Do resets ini.err to nil with each call. The err field of lazy.Init is not used outside of *Init.Do, so I removed it in order to simplify the code slightly and ensure that errors would not be part of an *Init's state. Instead, this change declares an error variable at the top of *Init.Do and assigns it in place of ini.err. After making this change, the go race detector began reporting a race in TestImageOps between one goroutine created in *Site.renderPages: ```go go pageRenderer(ctx, s, pages, results, wg) ``` ...and another goroutine created in *Init.withTimeout: ```go go func(cv chan verr) { v, err := f(ctx) c <- verr{v: v, err: err} }(c) ``` The race affected *pageContentOutput.content. To prevent this race, I added getter and setter methods for pageContentOutput.content that make use of a sync.RWMutex. Otherwise, this field is assigned/read directly by multiple goroutines. I made other changes in order to refactor the code and prevent unintentional memory sharing: - Removed lazy.AddWithTimeout and its tests. This function is not called anywhere, and removing it makes it slightly easier to make sense of the lazy package. - Edited the *Init.withTimeout to remove a redundant select statement. - Edited *onceMore.Do to return an error, making it a bit more straightforward to share errors between its function argument and its caller without risking unintentional memory sharing. Fixes gohugoio#7043
Having this issue also. I changed the file from this:
You can see I forgot to add the comma after 2nd array item. This threw the error: I first added the needed comma and tried to reload the page. both by clicking the "Reload Page" link on the error page AND by doing a Force Reload with the browser. The page does not refresh. I went back and removed my 3rd slide completely from the /data/slide.json (including the comma added after the 2nd slide) and saved it. I then again tried to reload the page. both by clicking the "Reload Page" link on the error page AND by doing a Force Reload with the browser. The page does not refresh - still shows the original error message. Even attempting to load the site in another BROWSER results in the same original error message page. Going back to my Command Prompt, I see that Hugo detected each change I made in the /data/slide.json document: ERROR 2021/12/01 12:25:58 Failed to load data: failed to load data: "D:\Hugo\HugoSites\cheeky\data\slide.json:11:1": unmarshal failed: invalid character '{' after array element Killing Hugo (Windows: ctrl -C) Resulted in a solution. In fact, I changed the /data/slide.json file CORRECTLY and now the 3rd slide loads with my title. |
To prevent sticky errors on server rebuilds. Fixes gohugoio#7043 Closes gohugoio#9194
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Since you are working on #7042 , i believe this bug also in the same topic.
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
Yes.
When hugo failed to parse data in
/data
directory, Hugo not recover even after we fixed the invalid datait happened to all three formats (
toml
,yaml
,json
)Let's says we have this
/data/testdata.json
.Reproducing The Bug
but after editing a
config
file, Hugo trigger full rebuild, then the ERROR gone.a repo to repoduce the bug
hugo-data-error-reload
The text was updated successfully, but these errors were encountered: