Comments (7)
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.
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 pipe
ing the readable to disk... https://replit.com/@GabrielSpeed/RipeAltruisticTransformation#index.js
from js-car.
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.
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.
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 put
s; there is a lot of code written to accommodate this behavior... (and when you actually use it, it just produces bugs...)
from js-car.
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 (await
ing the out
chunks while also await
ing the writer
writes, you'll just get stuck).
from js-car.
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 await
ing write
s 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)
- Can't resolve import when using @ipld/car from jest HOT 2
- Premature exit of reader when consuming an iterable stream with empty blocks HOT 2
- CarWriter.fromIterable(roots, blockIterator) HOT 1
- Propsoal: New API to create a writer with unknown root HOT 2
- Proposal: Sync Writer API HOT 2
- Proposal: make CarReader API sync HOT 5
- reading from a file object HOT 6
- CarReader.fromIterable for large files HOT 1
- Add support for WebStreams HOT 6
- Option to validate CID matches block HOT 4
- `CarBufferWriter` should be exported by index-browser HOT 3
- No "exports" main defined HOT 4
- What is the proper way to get CAR content without the `carHeader` HOT 2
- dag-json support for CarReader.fromBytes HOT 1
- tsize is too large? HOT 1
- Export a version from the writer HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-car.