How to pipe the archive in stream hono?

const streamPipe = new PassThrough();
archive.pipe(streamPipe);

const write = new WritableStream();


return stream(
c,
async (stream) => {
streamPipe.pipe(stream);
},
async (err, stream) => {
stream.writeln("An error occurred while streaming the file.");
logger.error(err);
}
);
const streamPipe = new PassThrough();
archive.pipe(streamPipe);

const write = new WritableStream();


return stream(
c,
async (stream) => {
streamPipe.pipe(stream);
},
async (err, stream) => {
stream.writeln("An error occurred while streaming the file.");
logger.error(err);
}
);
7 Replies
Mosh Ontong
Mosh OntongOP2w ago
Error: Argument of type 'StreamingApi' is not assignable to parameter of type 'WritableStream'. Type 'StreamingApi' is missing the following properties from type 'WritableStream': writable, end, addListener, on, and 13 more.ts(2345) (parameter) stream: StreamingApi By the way I am using bun with hono
ambergristle
ambergristle2w ago
Syntax highlighting please @Mosh Ontong where are you getting PassThrough from? and how is archive initialized?
Mosh Ontong
Mosh OntongOP2w ago
node I already higlight with js
Mosh Ontong
Mosh OntongOP2w ago
Is there another way to use the archive in hono?
ambergristle
ambergristle2w ago
no idea if that lib is compatible w bun. if not, this might be an alternative: https://bun.sh/guides/util/gzip it seems like your goal is to take a stream, compress it, and then return it to the user, yeah? have you tried
// const streamPipe = new PassThrough();
// archive.pipe(streamPipe);

stream(c, async (stream) => {
stream.pipe(archive);
// streamPipe.pipe(stream);
})
// const streamPipe = new PassThrough();
// archive.pipe(streamPipe);

stream(c, async (stream) => {
stream.pipe(archive);
// streamPipe.pipe(stream);
})
also
My problem right now is server crash when the file is 2000
2000 what?

Did you find this page helpful?