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

Cannot create a string longer than 0x1fffffe8 characters #156

Open
huksley opened this issue Jan 12, 2023 · 2 comments
Open

Cannot create a string longer than 0x1fffffe8 characters #156

huksley opened this issue Jan 12, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@huksley
Copy link

huksley commented Jan 12, 2023

Running it in GitHub CI results in the following error:

Run vio/bundle-stats-action@v1
  with:
    id: bundle-stats-nodejs
    webpack-stats-path: .next/server/stats/webpack-nodejs-stats.json
    repo-token: ***
  env:
    MSYS: winsymlinks:nativestrict
Error: Cannot create a string longer than 0x1fffffe8 characters

I tried googling it and it related to out of memory error and JSON serialization/deserialization.

In my other project, using JSON.serialize() is an OOM,
so I was using

const { stringifyStream } = require("@discoveryjs/json-ext");

stringifyStream(stats.toJson(this.statsOptions))
        .on("end", () => callback())
        .on("error", e => callback(e))
        .pipe(fs.createWriteStream(file));
@vio
Copy link
Owner

vio commented Jan 12, 2023

Thanks for creating the issue @huksley!

I can confirm that bundle-stats reads the file sync and fails when the file size is larger than nodejs can handle (existing issue: relative-ci/bundle-stats#2118).

In the meantime, you can try to export a smaller webpack-stats json file, for example, with webpack-stats-plugin you can instruct webpack to export only assets, chunks and module information: https://relative-ci.com/documentation/guides/webpack-stats/next.js/#configure

@vio vio added the bug Something isn't working label Jan 12, 2023
@vio
Copy link
Owner

vio commented Jan 18, 2023

@huksley i revisited the code, and while the JSON reading is async, the parsing is sync (JSON.parse).

I think that it will be useful to implement an async way of loading and parsing the JSON, but because bundle-stats uses only ~10MB of data from the webpack stats of a large project (500 assets, 15K modules), i think it is more appropiate for now to output less data. A smaller webpack stats JSON file means faster builds and lower costs for CI storing/transferring. Here is a way to optimize the webpack stats JSON to the minimum required data for bundle-stats: https://relative-ci.com/documentation/guides/webpack-stats/webpack-stats-plugin/#optimize-the-webpack-stats-json-file-size

Feel free to keep the issue open so you can get notified when bundle-stats#2118 feature will be ready, though no plans for when is it going to be implemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants