Skip to content

Gatsby redux save-state causes excessive disk usage #39282

Open
@ankurparihar

Description

@ankurparihar

Preliminary Checks

Description

Due to not handling of failure here, for any failed i, files from 0 - i-1, remains on the disk, and with each build they keep growing resulting in high disk usage.

writeFileSync(
reduxChunkedPagesFilePrefix(targetDir) + i,
v8.serialize(values.slice(i * chunkSize, i * chunkSize + chunkSize))
)

Each build creates a unique tmpdir - https://github.com/gatsbyjs/gatsby/blob/e8e17e774c4a90333a2277b44733bb4b48f2e102/packages/gatsby/src/redux/persist.ts#L237C18-L237C29

In scenarios, where buffer size exceeds serialization limits, it breaks the for loop.

Reproduction Link

NA

Steps to Reproduce

Cannot share as it's private repo.

Here's a screen recording

2.mp4

Expected Result

Files should be cleaned up properly

Actual Result

Files are not being cleaned up

Environment

NA

Config Flags

NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: triage neededIssue or pull request that need to be triaged and assigned to a reviewertype: bugAn issue or pull request relating to a bug in Gatsby

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions