-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Cache persisting fails #36062
Comments
Hi @and-who, thanks for the detailed issue description. What Gatsby version are you using? We no longer serialize nodes this way (they're now stored in lmdb), but pages still hit this code path. |
Currently we are using Gatsby 3 |
@and-who , while we can't promise upgrading to Gatsby 4 will fix the issue, it might see positive results. There were many changes to how the data is handled and the methods used to fetch data behind the scenes. Could you try an upgrade and see if the issue persists? I agree that this method of caching our redux state should be revisited, nonetheless, just a matter of timing. If any fixes do come through, they will only be in Gatsby v4. Thank you for reaching out, and thanks for using Gatsby! 💜 |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. Thanks for being a part of the Gatsby community! 💪💜 |
It took some Time because we have a large Project but we migrated to Gatsby4 on Prod now. So for now it looks good. If the Issue appears again I will come back to you. Thanks |
Preliminary Checks
Description
After a build is finished, gatsby tries to persist its Data in Cache Files.
This could Fail and result in the Following Error, e.g.:
warn Error persisting state: The value of "length" is out of range. It must be >= 0 && <= 2147483647. Received 2329483714
This Error Origins from the Gatsby Save State Funktion (v8.serialize())
gatsby/packages/gatsby/src/redux/save-state.js
Line 16 in eef99cc
The Problem is, that this Function uses a function to "guessSafeChunkSize"
gatsby/packages/gatsby/src/redux/persist.ts
Lines 101 to 118 in d20a74b
and this Guess can be wrong which results in the Error mentioned above.
As one of your Developers mentioned "This heuristic could still fail if it randomly grabs the smallest nodes"
We are currently stuck with this Problem, because of our large number of nodes "step" will most likely be the same Value even when there are nodes added or removed. Therefore the values which are used to guess the Chunk Size are the same, therefore the guess will be "wrong" even after the next build.
There is a Experimental Flag "GATSBY_DISABLE_CACHE_PERSISTENCE", this is no Option, because we have a system for Incremental Builds, which relies on the Cache Data.
There was a PR which tried to make this Problem more controllable, sadly it got closed and not merged:
#29039
Reproduction Link
gatsby/packages/gatsby/src/redux/persist.ts
Lines 108 to 111 in d20a74b
Steps to Reproduce
Sadly this is hard to reproduce, you'll need a specific set of Nodes, so that the Heuristic picks bad Nodes to determine the Chunk Size.
This Problem occurs on our Production Environment, the Data there is multiple GB large.
Expected Result
The Caching persisting should be Fail save.
If this is not possible make the heuristic adjustable, e.g. Make it possible to change the Number of Nodes which get chosen,
or randomize the choosing of the Test Nodes a bit more, so subsequent builds wont fail.
And perhaps return an Error not a Warning, so we can detect corrupted Data.
Actual Result
The Persisting of the Cache Data fails for unlucky Data.
We have no way of controlling this.
Environment
OS: macOS 12.4 CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz Shell: 5.8 - /usr/local/bin/zsh Binaries: Node: 16.7.0 - /var/folders/p7/2kyvkfcs387899__10tmf9gh0000gp/T/yar n--1657020894305-0.5687446657165263/node Yarn: 1.22.17 - /var/folders/p7/2kyvkfcs387899__10tmf9gh0000gp/T/ya rn--1657020894305-0.5687446657165263/yarn npm: 7.20.3 - ~/.nvm/versions/node/v16.7.0/bin/npm Browsers: Chrome: 103.0.5060.114 Firefox: 101.0.1 Safari: 15.5
Config Flags
No response
The text was updated successfully, but these errors were encountered: