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

Reader of ReadStream.toWeb does not return done: true on readStream finish #44866

Open
acomanescu opened this issue Oct 2, 2022 · 0 comments

Comments

@acomanescu
Copy link
Contributor

Version

18.9.0

Platform

macOS

Subsystem

No response

What steps will reproduce the bug?

I've tried the .toWeb approach to convert ServerHttp2Stream to a web stream, but it seems that reader.read() never returns done: true on readable stream finish. ReadableState of ServerHttp2Stream says that readable is finished.

import { createSecureServer } from 'node:http2';
import { Duplex } from 'node:stream';

const options = {};
const sever = createSecureServer(options);

server.on('stream', (stream) => {
  const { readable, writable } = Duplex.toWeb(stream);
  
  const reader = readable.getReader();
  
  while (true) {
    const result = await reader.read();
    console.log(result);  // { value: "<data>", done: false }
  }
});

server.listen(3000);

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior?

I expect to receive done: true after readable stream finish event.

What do you see instead?

I receive done: false.

Additional information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants