GithubHelp home page GithubHelp logo

Comments (7)

piboistudios avatar piboistudios commented on June 9, 2024

Also, what was interesting is that if you use writer._encoder.close() directly, it works fine... for a while.

It will still eventually close the process if you run enough operations concurrently (on separate writers). Definitely something going on with the encoder.

from js-car.

piboistudios avatar piboistudios commented on June 9, 2024

So, apparently, the CAR Writer only works if the AsyncIterable<UInt8Array> is converted to a node Stream at some point (e.g. via Readable.from(out).pipe(fs.createWriteStream('test' + '.car'))).

If you try to consume the AsyncIterable directly, the entire application will crash.

REPL showing the program executes to completion when you add a line converting it to a readable and pipeing the readable to disk... https://replit.com/@GabrielSpeed/RipeAltruisticTransformation#index.js

from js-car.

piboistudios avatar piboistudios commented on June 9, 2024

Yeah... there is something quite unstable about how this library is writing CARs.

I have, at this point, had to wrap the code dealing with the CarWriter with a call from async.retry to have it retry a few times as it would randomly fail with the reasoning being Unexpected end of data

from js-car.

piboistudios avatar piboistudios commented on June 9, 2024

The CarBlockIterator's static method fromIterable also produces an iterable that appears to just hang.

Causing ipfs.dag.import to likewise, just hang: https://github.com/ipfs/js-ipfs/blob/b64d4af034f27aa7204e57e6a79f95461095502c/packages/ipfs-core/src/components/dag/import.js#L92

This is using the CAR produced by the CarWriter class.

The CAR file: https://filebin.net/s55v8pfj6b52q0ia

from js-car.

piboistudios avatar piboistudios commented on June 9, 2024

It seems like all of the issues with this library, for writing at least, stem from the fact that the writer attempts to allow concurrent puts; there is a lot of code written to accommodate this behavior... (and when you actually use it, it just produces bugs...)

from js-car.

rvagg avatar rvagg commented on June 9, 2024

I hope the venting was therapeutic. But a word of advice - if you want help from authors of open source libraries, abuse and criticism that isn't framed constructively rarely leads to positive outcomes.

This looks like simply a usage issue here, or a misunderstanding about what is going on.

    const { writer, out } = await CarWriter.create();
    console.log('lol');
    await writer.close();

What are you expecting to happen here? The CAR writer is trying to write a header somewhere but you're not consuming it. out needs to go somewhere, it the whole construct can't be closed and cleaned up until that's flushed.

If you need to steam I'd also recommend using pipeline() rather than pipe() directly so you get errors handled properly.

Set up your out consumption before you write into writer. You also need to take care of the asynchronous nature of the flow, you can't manage both of these things in the same flow (awaiting the out chunks while also awaiting the writer writes, you'll just get stuck).

from js-car.

piboistudios avatar piboistudios commented on June 9, 2024

What are you expecting to happen here?

    .catch(e => {
        console.error('ERROR:', e); // no errors either
    })

Really anything but the program silently closing.

The CAR writer is trying to write a header somewhere but you're not consuming it. out needs to go somewhere, it the whole construct can't be closed and cleaned up until that's flushed.

This behavior also occurs if the CAR Writer is instantiated with roots. It's not related to the CAR being empty at all, and if that is in fact incorrect behavior, you should throw an error... especially now knowing that in this case the program will just silently close.

Set up your out consumption before you write into writer. You also need to take care of the asynchronous nature of the flow, you can't manage both of these things in the same flow (awaiting the out chunks while also awaiting the writer writes, you'll just get stuck).

How is that at all intuitive or obvious from any of the documentation, examples or test cases the library has?

The documentation presents awaiting writes as an option, not a requirement if you are awaiting downstream.

The way you are intending this library to be used is not forthcoming at all.

from js-car.

Related Issues (17)

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.