Code Monkey home page Code Monkey logo

Comments (9)

Suyashtnt avatar Suyashtnt commented on July 17, 2024 1

Thanks for the report @Suyashtnt, unfortunately this will take a bit of research and debugging to fix, which I haven't had the time for yet, and I can't make any promises on when I'll be able to get to it.

I no longer use NX, but for the people who do just take your time :)

from cargo.

dannymcgee avatar dannymcgee commented on July 17, 2024

Thanks for the report @Suyashtnt, unfortunately this will take a bit of research and debugging to fix, which I haven't had the time for yet, and I can't make any promises on when I'll be able to get to it.

from cargo.

IgnisDa avatar IgnisDa commented on July 17, 2024

@dannymcgee I would like to contribute a fix for this. I have isolated the problem. Would you be willing to accept a pull request?

from cargo.

IgnisDa avatar IgnisDa commented on July 17, 2024

@dannymcgee I made a PR fixing this.

from cargo.

dannymcgee avatar dannymcgee commented on July 17, 2024

@IgnisDa Thank you so much! I'll try to get this merged in today.

from cargo.

robi-wan avatar robi-wan commented on July 17, 2024

We are currently also running into this issue.
Liked mentioned in #21 the issue is that the output of cargo metadata is too large, it overflowed the buffer.

A minimal viable patch which works locally is taking this line maxBuffer: 50 * 1024 * 1024,
and adding it to the execSync call:

    let metadata = cp.execSync("cargo metadata --format-version=1", {
        encoding: "utf8",
        maxBuffer: 50 * 1024 * 1024,
    });

Another approach would be the usage of child_process.spawn.
See https://stackoverflow.com/a/68958420

from cargo.

IgnisDa avatar IgnisDa commented on July 17, 2024

@robi-wan I forked this repo and published the correct fix here: https://github.com/IgnisDa/npm-libs/tree/main/packages/nx-rust.

The solution you have posted will work but only for metadata below 50mb. For big projects, it would be more than that. It needs to be implemented using json streaming.

from cargo.

robi-wan avatar robi-wan commented on July 17, 2024

@IgnisDa Thank you for this info - a possible workaround for us would be to use your fork with that fix.

My understanding of Nodejs code is not very good but regarding my understanding the root cause for this issue is the limited buffer used in child_process.execSync: the default buffer size for stdout is 1024 * 1024 (see https://github.com/nodejs/node/blob/91ca2d40419244a9c542be5ff162a837fcc3be82/lib/child_process.js#L95).
It even is the default when using child_process.spawnSync without changes in handling I/O to the spawned process.

(In your fix you also used child_process.execSync with an extended buffer of 50 MB - so as I understand it your solution would also fail for big projects?)

You are right: streaming is the right approach but it should not just be used for JSON parsing. It should also be used for fetching the process output - I think therefore instead of child_process.execSync child_process.spawnSync should be used and something has to be done to redirect the stdout of cargo metadata --format-version=1 into a resizable buffer or a stream.

from cargo.

IgnisDa avatar IgnisDa commented on July 17, 2024

@robi-wan Indeed I have increased the buffer size, but then later I have also parsed the json via streaming. You can see them here https://github.com/IgnisDa/npm-libs/blob/main/packages/nx-rust/src/graph/index.ts#L23-L37.

I think therefore instead of child_process.execSync child_process.spawnSync should be used and something has to be done to redirect the stdout of cargo metadata --format-version=1 into a resizable buffer or a stream.

I am not sure about this. I will try to test this theory once I have time.

from cargo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.